mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 05:14:35 +00:00
Discovery patch (#2382)
* Upgrade libp2p and unstable gossip * Network protocol upgrades * Correct dependencies, reduce incoming bucket limit * Clean up dirty DHT entries before repopulating * Update cargo lock * Update lockfile * Update ENR dep * Update deps to specific versions * Update test dependencies * Update docker rust, and remote signer tests * More remote signer test fixes * Temp commit * Update discovery * Remove cached enrs after dialing * Increase the session capacity, for improved efficiency
This commit is contained in:
@@ -295,6 +295,11 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
self.cached_enrs.iter()
|
||||
}
|
||||
|
||||
/// Removes a cached ENR from the list.
|
||||
pub fn remove_cached_enr(&mut self, peer_id: &PeerId) -> Option<Enr> {
|
||||
self.cached_enrs.pop(peer_id)
|
||||
}
|
||||
|
||||
/// This adds a new `FindPeers` query to the queue if one doesn't already exist.
|
||||
pub fn discover_peers(&mut self) {
|
||||
// If the discv5 service isn't running or we are in the process of a query, don't bother queuing a new one.
|
||||
@@ -502,6 +507,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) {
|
||||
@@ -514,11 +520,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 */
|
||||
|
||||
Reference in New Issue
Block a user