Ensure disconnecting peers are added to the peerdb (#2451)
This commit is contained in:
parent
059d9ec1b1
commit
381befbf82
@ -319,7 +319,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
self.network_globals
|
self.network_globals
|
||||||
.peers
|
.peers
|
||||||
.write()
|
.write()
|
||||||
.notify_disconnecting(&peer_id, true);
|
.notify_disconnecting(peer_id, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
self.network_globals
|
self.network_globals
|
||||||
.peers
|
.peers
|
||||||
.write()
|
.write()
|
||||||
.notify_disconnecting(&peer_id, false);
|
.notify_disconnecting(peer_id, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1023,7 +1023,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
|
|
||||||
let mut peer_db = self.network_globals.peers.write();
|
let mut peer_db = self.network_globals.peers.write();
|
||||||
for peer_id in disconnecting_peers {
|
for peer_id in disconnecting_peers {
|
||||||
peer_db.notify_disconnecting(&peer_id, false);
|
peer_db.notify_disconnecting(peer_id, false);
|
||||||
self.events.push(PeerManagerEvent::DisconnectPeer(
|
self.events.push(PeerManagerEvent::DisconnectPeer(
|
||||||
peer_id,
|
peer_id,
|
||||||
GoodbyeReason::TooManyPeers,
|
GoodbyeReason::TooManyPeers,
|
||||||
|
@ -475,10 +475,11 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
|||||||
|
|
||||||
/// Notifies the peer manager that the peer is undergoing a normal disconnect. Optionally tag
|
/// Notifies the peer manager that the peer is undergoing a normal disconnect. Optionally tag
|
||||||
/// the peer to be banned after the disconnect.
|
/// the peer to be banned after the disconnect.
|
||||||
pub fn notify_disconnecting(&mut self, peer_id: &PeerId, to_ban_afterwards: bool) {
|
pub fn notify_disconnecting(&mut self, peer_id: PeerId, to_ban_afterwards: bool) {
|
||||||
if let Some(info) = self.peers.get_mut(peer_id) {
|
self.peers
|
||||||
info.disconnecting(to_ban_afterwards);
|
.entry(peer_id)
|
||||||
}
|
.or_default()
|
||||||
|
.disconnecting(to_ban_afterwards);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Marks a peer to be disconnected and then banned.
|
/// Marks a peer to be disconnected and then banned.
|
||||||
|
Loading…
Reference in New Issue
Block a user