Skip to content

Commit

Permalink
Remove retain_mut crate (paritytech#11926)
Browse files Browse the repository at this point in the history
* Remove retain_mut crate

* Remove reain_mut crate from babe-consensus
  • Loading branch information
skunert authored Jul 27, 2022
1 parent 9acfbc0 commit dddfed3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 38 deletions.
8 changes: 0 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion client/consensus/babe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ num-rational = "0.2.2"
num-traits = "0.2.8"
parking_lot = "0.12.0"
rand = "0.7.2"
retain_mut = "0.1.4"
schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated"] }
serde = { version = "1.0.136", features = ["derive"] }
thiserror = "1.0"
Expand Down
22 changes: 10 additions & 12 deletions client/consensus/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ use futures::{
use log::{debug, info, log, trace, warn};
use parking_lot::Mutex;
use prometheus_endpoint::Registry;
use retain_mut::RetainMut;
use schnorrkel::SignatureError;

use sc_client_api::{
Expand Down Expand Up @@ -835,17 +834,16 @@ where
slot: Slot,
epoch_descriptor: &ViableEpochDescriptor<B::Hash, NumberFor<B>, Epoch>,
) {
RetainMut::retain_mut(&mut *self.slot_notification_sinks.lock(), |sink| {
match sink.try_send((slot, epoch_descriptor.clone())) {
Ok(()) => true,
Err(e) =>
if e.is_full() {
warn!(target: "babe", "Trying to notify a slot but the channel is full");
true
} else {
false
},
}
let sinks = &mut self.slot_notification_sinks.lock();
sinks.retain_mut(|sink| match sink.try_send((slot, epoch_descriptor.clone())) {
Ok(()) => true,
Err(e) =>
if e.is_full() {
warn!(target: "babe", "Trying to notify a slot but the channel is full");
true
} else {
false
},
});
}

Expand Down
1 change: 0 additions & 1 deletion client/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ linked-hash-map = "0.5.4"
log = "0.4.17"
parity-util-mem = { version = "0.11.0", default-features = false, features = ["primitive-types"] }
parking_lot = "0.12.0"
retain_mut = "0.1.4"
serde = { version = "1.0.136", features = ["derive"] }
thiserror = "1.0.30"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" }
Expand Down
30 changes: 14 additions & 16 deletions client/transaction-pool/src/graph/validated_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use std::{

use futures::channel::mpsc::{channel, Sender};
use parking_lot::{Mutex, RwLock};
use retain_mut::RetainMut;
use sc_transaction_pool_api::{error, PoolStatus, ReadyTransactions};
use serde::Serialize;
use sp_runtime::{
Expand Down Expand Up @@ -204,21 +203,20 @@ impl<B: ChainApi> ValidatedPool<B> {
let imported = self.pool.write().import(tx)?;

if let base::Imported::Ready { ref hash, .. } = imported {
RetainMut::retain_mut(&mut *self.import_notification_sinks.lock(), |sink| {
match sink.try_send(*hash) {
Ok(()) => true,
Err(e) =>
if e.is_full() {
log::warn!(
target: "txpool",
"[{:?}] Trying to notify an import but the channel is full",
hash,
);
true
} else {
false
},
}
let sinks = &mut self.import_notification_sinks.lock();
sinks.retain_mut(|sink| match sink.try_send(*hash) {
Ok(()) => true,
Err(e) =>
if e.is_full() {
log::warn!(
target: "txpool",
"[{:?}] Trying to notify an import but the channel is full",
hash,
);
true
} else {
false
},
});
}

Expand Down

0 comments on commit dddfed3

Please sign in to comment.