Skip to content

Commit

Permalink
Fix unexpected Marking peer disconnected in DHT (#6140)
Browse files Browse the repository at this point in the history
* Don't disconnect peer in DHT if there's an active connection

* Merge branch 'unstable' into dont-disconnect-if-active-connection
  • Loading branch information
ackintosh authored Jul 25, 2024
1 parent 4e5a363 commit 62a39af
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion beacon_node/lighthouse_network/src/discovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,8 +1166,19 @@ impl<E: EthSpec> Discovery<E> {
fn on_dial_failure(&mut self, peer_id: Option<PeerId>, error: &DialError) {
if let Some(peer_id) = peer_id {
match error {
DialError::Denied { .. } => {
if self.network_globals.peers.read().is_connected(&peer_id) {
// There's an active connection, so we don’t disconnect the peer.
// Lighthouse dials to a peer twice using TCP and QUIC (if QUIC is not
// disabled). Usually, one establishes a connection, and the other fails
// because the peer allows only one connection per peer.
return;
}
// set peer as disconnected in discovery DHT
debug!(self.log, "Marking peer disconnected in DHT"; "peer_id" => %peer_id, "error" => %ClearDialError(error));
self.disconnect_peer(&peer_id);
}
DialError::LocalPeerId { .. }
| DialError::Denied { .. }
| DialError::NoAddresses
| DialError::Transport(_)
| DialError::WrongPeerId { .. } => {
Expand Down

0 comments on commit 62a39af

Please sign in to comment.