Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-revert optimistic peer reconnect #1010

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions crates/services/p2p/src/p2p_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,16 +461,9 @@ impl<Codec: NetworkCodec> FuelP2PService<Codec> {
}
return Some(FuelP2PEvent::PeerDisconnected(peer_id))
}
PeerInfoEvent::TooManyPeers {
peer_to_disconnect,
peer_to_connect,
} => {
PeerInfoEvent::TooManyPeers { peer_to_disconnect } => {
// disconnect the surplus peer
let _ = self.swarm.disconnect_peer_id(peer_to_disconnect);
// reconnect the reserved peer
if let Some(peer_id) = peer_to_connect {
let _ = self.swarm.dial(peer_id);
}
}
},
FuelBehaviourEvent::RequestResponse(req_res_event) => match req_res_event {
Expand Down
9 changes: 0 additions & 9 deletions crates/services/p2p/src/peer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ pub enum PeerInfoEvent {
},
TooManyPeers {
peer_to_disconnect: PeerId,
peer_to_connect: Option<PeerId>,
},
ReconnectToPeer(PeerId),
PeerIdentified {
Expand Down Expand Up @@ -596,13 +595,6 @@ impl PeerManager {
.filter(|peer_id| !self.reserved_connected_peers.contains_key(peer_id))
}

fn find_disconnected_reserved_peer(&self) -> Option<PeerId> {
self.reserved_peers
.iter()
.find(|peer_id| self.reserved_connected_peers.contains_key(peer_id))
.cloned()
}

/// Handles the first connnection established with a Peer
fn handle_initial_connection(&mut self, peer_id: PeerId) {
let non_reserved_peers_connected = self.non_reserved_connected_peers.len();
Expand All @@ -614,7 +606,6 @@ impl PeerManager {
// Too many peers already connected, disconnect the Peer with the first priority.
self.pending_events.push_front(PeerInfoEvent::TooManyPeers {
peer_to_disconnect: peer_id,
peer_to_connect: self.find_disconnected_reserved_peer(),
});

// early exit, we don't want to report new peer connection
Expand Down