Skip to content

Commit

Permalink
Merge pull request AleoNet#3330 from ljedrz/fix/3326
Browse files Browse the repository at this point in the history
[Fix] Clear seen_outbound_block_requests on peer disconnect
  • Loading branch information
zosorock authored Oct 22, 2024
2 parents 38d0973 + 5be228b commit 411940b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions node/router/src/helpers/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ impl<N: Network> Cache<N> {
pub fn decrement_outbound_peer_requests(&self, peer_ip: SocketAddr) -> u32 {
Self::decrement_counter(&self.seen_outbound_peer_requests, peer_ip)
}

/// Removes all cache entries applicable to the given key.
pub fn clear_peer_entries(&self, peer_ip: SocketAddr) {
self.seen_outbound_block_requests.write().remove(&peer_ip);
}
}

impl<N: Network> Cache<N> {
Expand Down
2 changes: 2 additions & 0 deletions node/router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ impl<N: Network> Router<N> {
self.connected_peers.write().remove(&peer_ip);
// Add the peer to the candidate peers.
self.candidate_peers.write().insert(peer_ip);
// Clear cached entries applicable to the peer.
self.cache.clear_peer_entries(peer_ip);
#[cfg(feature = "metrics")]
self.update_metrics();
}
Expand Down

0 comments on commit 411940b

Please sign in to comment.