Filter Disconnected Peers from Discv5 DHT (#2219)
## Issue Addressed #2107 ## Proposed Change The peer manager will mark peers as disconnected in the discv5 DHT when they disconnect or dial fails ## Additional Info Rationale for this particular change is explained in my comment on #2107
This commit is contained in:
parent
0754ba3be7
commit
0aa8509525
@ -514,6 +514,13 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -327,6 +327,9 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user