mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(net/peer): remove the duplicated disconnect logic (#9162)
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
@ -325,15 +325,6 @@ impl PeersManager {
|
|||||||
peer.state = PeerConnectionState::In;
|
peer.state = PeerConnectionState::In;
|
||||||
|
|
||||||
is_trusted = is_trusted || peer.is_trusted();
|
is_trusted = is_trusted || peer.is_trusted();
|
||||||
|
|
||||||
// if a peer is not trusted and we don't have capacity for more inbound connections,
|
|
||||||
// disconnecting the peer
|
|
||||||
if !is_trusted && !has_in_capacity {
|
|
||||||
self.queued_actions.push_back(PeerAction::Disconnect {
|
|
||||||
peer_id,
|
|
||||||
reason: Some(DisconnectReason::TooManyPeers),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Entry::Vacant(entry) => {
|
Entry::Vacant(entry) => {
|
||||||
// peer is missing in the table, we add it but mark it as to be removed after
|
// peer is missing in the table, we add it but mark it as to be removed after
|
||||||
@ -342,16 +333,16 @@ impl PeersManager {
|
|||||||
peer.remove_after_disconnect = true;
|
peer.remove_after_disconnect = true;
|
||||||
entry.insert(peer);
|
entry.insert(peer);
|
||||||
self.queued_actions.push_back(PeerAction::PeerAdded(peer_id));
|
self.queued_actions.push_back(PeerAction::PeerAdded(peer_id));
|
||||||
|
|
||||||
// disconnect the peer if we don't have capacity for more inbound connections
|
|
||||||
if !is_trusted && !has_in_capacity {
|
|
||||||
self.queued_actions.push_back(PeerAction::Disconnect {
|
|
||||||
peer_id,
|
|
||||||
reason: Some(DisconnectReason::TooManyPeers),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disconnect the peer if we don't have capacity for more inbound connections
|
||||||
|
if !is_trusted && !has_in_capacity {
|
||||||
|
self.queued_actions.push_back(PeerAction::Disconnect {
|
||||||
|
peer_id,
|
||||||
|
reason: Some(DisconnectReason::TooManyPeers),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bans the peer temporarily with the configured ban timeout
|
/// Bans the peer temporarily with the configured ban timeout
|
||||||
|
|||||||
Reference in New Issue
Block a user