diff --git a/beacon_node/eth2_libp2p/src/discovery/mod.rs b/beacon_node/eth2_libp2p/src/discovery/mod.rs index 0664ec6d8..5f043d877 100644 --- a/beacon_node/eth2_libp2p/src/discovery/mod.rs +++ b/beacon_node/eth2_libp2p/src/discovery/mod.rs @@ -514,6 +514,13 @@ impl Discovery { } } + // mark node as disconnected in DHT, freeing up space for other nodes + pub fn disconnect_peer(&mut self, peer_id: &PeerId) { + if let Ok(node_id) = peer_id_to_node_id(peer_id) { + self.discv5.disconnect_node(&node_id); + } + } + /* Internal Functions */ /// Adds a subnet query if one doesn't exist. If a subnet query already exists, this diff --git a/beacon_node/eth2_libp2p/src/peer_manager/mod.rs b/beacon_node/eth2_libp2p/src/peer_manager/mod.rs index eeef06d07..3269fbf26 100644 --- a/beacon_node/eth2_libp2p/src/peer_manager/mod.rs +++ b/beacon_node/eth2_libp2p/src/peer_manager/mod.rs @@ -327,6 +327,9 @@ impl PeerManager { pub fn notify_dial_failure(&mut self, peer_id: &PeerId) { if !self.network_globals.peers.read().is_connected(peer_id) { self.notify_disconnect(peer_id); + // set peer as disconnected in discovery DHT + debug!(self.log, "Marking peer disconnected in DHT"; "peer_id" => %peer_id); + self.discovery.disconnect_peer(peer_id); } }