Skip to content

Commit de99d16

Browse files
committed
improved cleanup of unfetched_pooled_transactions, depending witch collection is larger, we choose the appropriate method.
1 parent 5bcf071 commit de99d16

File tree

1 file changed

+14
-4
lines changed
  • crates/ethcore/sync/src/chain

1 file changed

+14
-4
lines changed

crates/ethcore/sync/src/chain/mod.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,10 +1447,20 @@ impl ChainSync {
14471447
// and if we have nothing else to do, get the peer to give us at least some of announced but unfetched transactions
14481448
let mut to_send = H256FastSet::default();
14491449
if let Some(peer) = self.peers.get_mut(&peer_id) {
1450-
// info: this check should do nothing, if everything is tracked correctly,
1451-
1452-
peer.unfetched_pooled_transactions
1453-
.retain(|h| !self.lately_received_transactions.contains(h));
1450+
// remove lately received transactions from unfetched list
1451+
// depending witch collection is larger, we choose the appropriate method.
1452+
if self.lately_received_transactions.len() > 0 {
1453+
if peer.unfetched_pooled_transactions.len()
1454+
> self.lately_received_transactions.len()
1455+
{
1456+
self.lately_received_transactions.iter().for_each(|h| {
1457+
peer.unfetched_pooled_transactions.remove(h);
1458+
});
1459+
} else {
1460+
peer.unfetched_pooled_transactions
1461+
.retain(|h| !self.lately_received_transactions.contains(h));
1462+
}
1463+
}
14541464

14551465
if peer.asking_pooled_transactions.is_empty() {
14561466
// todo: we might just request the same transactions from multiple peers here, at the same time.

0 commit comments

Comments
 (0)