Skip to content

Commit

Permalink
Revert "Merge pull request AleoNet#3254 from niklaslong/fix/cache"
Browse files Browse the repository at this point in the history
This reverts commit 7ff06a8, reversing
changes made to 9cc67c9.
  • Loading branch information
zosorock committed May 24, 2024
1 parent 223a1b5 commit 0829e52
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
5 changes: 0 additions & 5 deletions node/bft/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,11 +1085,6 @@ impl<N: Network> Disconnect for Gateway<N> {
async fn handle_disconnect(&self, peer_addr: SocketAddr) {
if let Some(peer_ip) = self.resolver.get_listener(peer_addr) {
self.remove_connected_peer(peer_ip);

// We don't clear this map based on time but only on peer disconnect.
// This is sufficient to avoid infinite growth as the committee has a fixed number
// of members.
self.cache.clear_outbound_validators_requests(peer_ip);
}
}
}
Expand Down
28 changes: 0 additions & 28 deletions node/bft/src/helpers/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ impl<N: Network> Cache<N> {
pub fn decrement_outbound_validators_requests(&self, peer_ip: SocketAddr) -> u32 {
Self::decrement_counter(&self.seen_outbound_validators_requests, peer_ip)
}

/// Clears the the IP's number of validator requests.
pub fn clear_outbound_validators_requests(&self, peer_ip: SocketAddr) {
self.seen_outbound_validators_requests.write().remove(&peer_ip);
}
}

impl<N: Network> Cache<N> {
Expand Down Expand Up @@ -298,27 +293,4 @@ mod tests {
outbound_certificate,
outbound_transmission
}

#[test]
fn test_seen_outbound_validators_requests() {
let cache = Cache::<CurrentNetwork>::default();
let input = Input::input();

// Check the map is empty.
assert!(!cache.contains_outbound_validators_request(input));

// Insert some requests.
for _ in 0..3 {
cache.increment_outbound_validators_requests(input);
assert!(cache.contains_outbound_validators_request(input));
}

// Remove a request.
cache.decrement_outbound_validators_requests(input);
assert!(cache.contains_outbound_validators_request(input));

// Clear all requests.
cache.clear_outbound_validators_requests(input);
assert!(!cache.contains_outbound_validators_request(input));
}
}

0 comments on commit 0829e52

Please sign in to comment.