Skip to content

Commit

Permalink
Temp commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AgeManning committed May 31, 2021
1 parent ec5cceb commit a7ccc25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
7 changes: 6 additions & 1 deletion beacon_node/eth2_libp2p/src/discovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
}
}

/// Unbans the peer in discovery.
pub fn unban_peer(&mut self, peer_id: &PeerId, ip_addresses: Vec<IpAddr>) {
// first try and convert the peer_id to a node_id.
if let Ok(node_id) = peer_id_to_node_id(peer_id) {
Expand All @@ -514,11 +515,15 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
}
}

// mark node as disconnected in DHT, freeing up space for other nodes
/// Marks node as disconnected in the DHT, freeing up space for other nodes, this also removes
/// nodes from the cached ENR list.
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);
}
// Remove the peer from the cached list, to prevent redialing disconnected
// peers.
self.cached_enrs.pop(peer_id);
}

/* Internal Functions */
Expand Down
9 changes: 1 addition & 8 deletions beacon_node/eth2_libp2p/src/peer_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
// ENR's may have multiple Multiaddrs. The multi-addr associated with the UDP
// port is removed, which is assumed to be associated with the discv5 protocol (and
// therefore irrelevant for other libp2p components).
let mut out_list = enr.multiaddr();
out_list.retain(|addr| {
addr.iter()
.find(|v| matches!(v, MProtocol::Udp(_)))
.is_none()
});

out_list
enr.multiaddr_tcp()
} else {
// PeerId is not known
Vec::new()
Expand Down

0 comments on commit a7ccc25

Please sign in to comment.