Skip to content

Comments

fix: disconnect peers after pong timeout#424

Open
xdustinface wants to merge 1 commit intov0.42-devfrom
fix/disconnect-after-pong-timeout
Open

fix: disconnect peers after pong timeout#424
xdustinface wants to merge 1 commit intov0.42-devfrom
fix/disconnect-after-pong-timeout

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Feb 8, 2026

Allow other peers to come in instead. I think the timeout of 60s is enough to get rid of them if they fail to pong.

Based on:

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection and disconnection of unresponsive peers
    • Enhanced cleanup of expired peer connection states
    • Better peer lifecycle management during network operations

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

Warning

Rate limit exceeded

@xdustinface has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 40 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

The changes enhance peer ping management in the network maintenance loop. The cleanup_old_pings method in the peer module now returns the count of expired pings, and the manager uses this count to determine which peers have expired pings and disconnects them, while also handling per-peer ping failures by updating reputation.

Changes

Cohort / File(s) Summary
Peer Ping Management
dash-spv/src/network/peer.rs
Modified cleanup_old_pings method to return a usize count of removed expired pings, with logic to collect expired nonces, remove them, log warnings, and return the count.
Network Manager Maintenance Loop
dash-spv/src/network/manager.rs
Enhanced maintenance loop to attempt sending pings to peers, handle ping failures with reputation updates, and use the count returned from cleanup_old_pings to identify and disconnect peers with expired pings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A ping here, a pong there,
Hopping through the network air,
Old pings cleaned, the count's now plain,
Peers expire in the loop's domain,
Tighter management, connections sane!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: implementing peer disconnection after ping/pong timeout, which is the core objective of the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/disconnect-after-pong-timeout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@dash-spv/src/network/manager.rs`:
- Around line 890-893: The maintenance loop calls pool.remove_peer(&addr) on
ping-timeout peers but doesn't decrement the cached connected_peer_count or emit
network events, causing counter drift and stale event state; modify the
maintenance loop closure to capture network_event_sender, and after successful
removal invoke the same cleanup path used in start_peer_reader: call
connected_peer_count.fetch_sub(1, Ordering::SeqCst) (or the existing decrement
helper), send NetworkEvent::PeerDisconnected with the peer id and then send
NetworkEvent::PeersUpdated so consumers stay in sync; ensure you reference
pool.remove_peer, connected_peer_count, network_event_sender, and mirror the
logic from start_peer_reader to avoid double-removal.

@xdustinface xdustinface marked this pull request as draft February 9, 2026 15:20
@github-actions github-actions bot added the merge-conflict The PR conflicts with the target branch. label Feb 12, 2026
@github-actions
Copy link

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@xdustinface xdustinface force-pushed the fix/disconnect-after-pong-timeout branch from da3067f to 2ae2f93 Compare February 14, 2026 01:56
@github-actions github-actions bot removed the merge-conflict The PR conflicts with the target branch. label Feb 14, 2026
@xdustinface xdustinface changed the base branch from v0.42-dev to refactor/remove-peer-helper February 14, 2026 01:57
@xdustinface xdustinface force-pushed the refactor/remove-peer-helper branch from 5b1bd05 to 3c52c6c Compare February 17, 2026 10:07
@github-actions github-actions bot added the merge-conflict The PR conflicts with the target branch. label Feb 17, 2026
@github-actions
Copy link

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@xdustinface xdustinface force-pushed the refactor/remove-peer-helper branch 2 times, most recently from cea4bcb to 8b91a53 Compare February 17, 2026 14:22
Base automatically changed from refactor/remove-peer-helper to v0.42-dev February 17, 2026 22:10
@xdustinface xdustinface force-pushed the fix/disconnect-after-pong-timeout branch from 2ae2f93 to 81b5856 Compare February 18, 2026 02:56
@github-actions github-actions bot removed the merge-conflict The PR conflicts with the target branch. label Feb 18, 2026
@github-actions
Copy link

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@github-actions github-actions bot added the merge-conflict The PR conflicts with the target branch. label Feb 18, 2026
Allow other peers to come in instead. I think the timeout of 60s is enough to get rid of them if they fail to pong.
@xdustinface xdustinface force-pushed the fix/disconnect-after-pong-timeout branch from 81b5856 to 8132edd Compare February 19, 2026 19:16
@xdustinface xdustinface marked this pull request as ready for review February 19, 2026 19:17
@github-actions github-actions bot removed the merge-conflict The PR conflicts with the target branch. label Feb 19, 2026
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.

1 participant