From 4405f1b3d3e2e61989f82205d7d7460cd07d5bab Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 16 Dec 2024 12:06:34 +0100 Subject: [PATCH] perf: remove redundant fallback cleanup (#13401) --- crates/net/network/src/transactions/fetcher.rs | 16 +--------------- crates/net/network/src/transactions/mod.rs | 1 - 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/crates/net/network/src/transactions/fetcher.rs b/crates/net/network/src/transactions/fetcher.rs index 9b072058faf7..77b4ed867e40 100644 --- a/crates/net/network/src/transactions/fetcher.rs +++ b/crates/net/network/src/transactions/fetcher.rs @@ -509,7 +509,6 @@ impl TransactionFetcher { new_announced_hashes: &mut ValidAnnouncementData, is_tx_bad_import: impl Fn(&TxHash) -> bool, peer_id: &PeerId, - is_session_active: impl Fn(PeerId) -> bool, client_version: &str, ) { let mut previously_unseen_hashes_count = 0; @@ -520,7 +519,7 @@ impl TransactionFetcher { new_announced_hashes.retain(|hash, metadata| { // occupied entry - if let Some(TxFetchMetadata{ref mut fallback_peers, tx_encoded_length: ref mut previously_seen_size, ..}) = self.hashes_fetch_inflight_and_pending_fetch.peek_mut(hash) { + if let Some(TxFetchMetadata{ tx_encoded_length: ref mut previously_seen_size, ..}) = self.hashes_fetch_inflight_and_pending_fetch.peek_mut(hash) { // update size metadata if available if let Some((_ty, size)) = metadata { if let Some(prev_size) = previously_seen_size { @@ -544,19 +543,6 @@ impl TransactionFetcher { if self.hashes_pending_fetch.remove(hash) { return true } - // hash has been seen and is in flight. store peer as fallback peer. - // - // remove any ended sessions, so that in case of a full cache, alive peers aren't - // removed in favour of lru dead peers - let mut ended_sessions = vec![]; - for &peer_id in fallback_peers.iter() { - if is_session_active(peer_id) { - ended_sessions.push(peer_id); - } - } - for peer_id in ended_sessions { - fallback_peers.remove(&peer_id); - } return false } diff --git a/crates/net/network/src/transactions/mod.rs b/crates/net/network/src/transactions/mod.rs index 7e87736cc49b..badb20c302ce 100644 --- a/crates/net/network/src/transactions/mod.rs +++ b/crates/net/network/src/transactions/mod.rs @@ -602,7 +602,6 @@ where &mut valid_announcement_data, |hash| bad_imports.contains(hash), &peer_id, - |peer_id| self.peers.contains_key(&peer_id), &client, );