Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(net/peer): remove the duplicated disconnect logic #9162

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions crates/net/network/src/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,6 @@ impl PeersManager {
peer.state = PeerConnectionState::In;

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) => {
// peer is missing in the table, we add it but mark it as to be removed after
Expand All @@ -342,16 +333,16 @@ impl PeersManager {
peer.remove_after_disconnect = true;
entry.insert(peer);
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
Expand Down
Loading