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

feat(p2p): outbound peer eviction #1748

Merged
merged 1 commit into from
Feb 12, 2024
Merged

feat(p2p): outbound peer eviction #1748

merged 1 commit into from
Feb 12, 2024

Conversation

sistemd
Copy link
Contributor

@sistemd sistemd commented Feb 7, 2024

Evict outbound peers for which useful = false when a new outbound connection is attempted. Did this first because it's simpler than inbound peer eviction.

Part of #1711.

@sistemd sistemd marked this pull request as ready for review February 7, 2024 13:22
@sistemd sistemd requested a review from a team as a code owner February 7, 2024 13:22
Comment on lines +502 to +507
let (peer_id, _) = candidates.pop().ok_or_else(|| {
tracing::debug!("Outbound peer limit reached, but no peers could be evicted");
ConnectionDenied::new(anyhow!(
"outbound peer limit reached and no peers could be evicted"
))
})?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also be done using the let Some(_) = .. else { .. }; syntax which saves a closure and highlights the control flow 🤷

@sistemd sistemd merged commit 98d21a8 into main Feb 12, 2024
7 checks passed
@sistemd sistemd deleted the sistemd/outbound-eviction branch February 12, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants