HashMap::retain
This commit is contained in:
parent
72907da2ae
commit
8b85f648ca
@ -57,10 +57,7 @@ impl Reservations {
|
|||||||
/// The reserved nonce cannot be smaller than the minimal nonce.
|
/// The reserved nonce cannot be smaller than the minimal nonce.
|
||||||
pub fn reserve(&mut self, sender: Address, minimal: U256) -> Reserved {
|
pub fn reserve(&mut self, sender: Address, minimal: U256) -> Reserved {
|
||||||
if self.nonces.len() + 1 > Self::CLEAN_AT {
|
if self.nonces.len() + 1 > Self::CLEAN_AT {
|
||||||
let to_remove = self.nonces.iter().filter(|&(_, v)| v.is_empty()).map(|(k, _)| *k).collect::<Vec<_>>();
|
self.nonces.retain(|_, v| !v.is_empty());
|
||||||
for address in to_remove {
|
|
||||||
self.nonces.remove(&address);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let pool = &self.pool;
|
let pool = &self.pool;
|
||||||
|
Loading…
Reference in New Issue
Block a user