Skip to content

Commit

Permalink
perf: remove redundant fallback cleanup (#13401)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 16, 2024
1 parent f36e369 commit 4405f1b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
16 changes: 1 addition & 15 deletions crates/net/network/src/transactions/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ impl<N: NetworkPrimitives> TransactionFetcher<N> {
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;
Expand All @@ -520,7 +519,7 @@ impl<N: NetworkPrimitives> TransactionFetcher<N> {
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 {
Expand All @@ -544,19 +543,6 @@ impl<N: NetworkPrimitives> TransactionFetcher<N> {
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
}
Expand Down
1 change: 0 additions & 1 deletion crates/net/network/src/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand Down

0 comments on commit 4405f1b

Please sign in to comment.