fix: maintenance loop stops connecting at 1 peer#437
Conversation
📝 WalkthroughWalkthroughThis PR removes Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@dash-spv/tests/peer_test.rs`:
- Line 185: The assertion in peer_test.rs uses TARGET_PEERS (constant defined as
3) but the failure message says "Default max peers should be 12"; update the
assertion message to reflect the actual expected value by changing the message
to "Default max peers should be 3" (locate the assert_eq!(TARGET_PEERS, 3, ...)
in the test and replace the string), ensuring consistency between TARGET_PEERS
and the human-readable assertion text.
🧹 Nitpick comments (1)
dash-spv/src/network/pool.rs (1)
152-160:needs_more_peersandcan_accept_peersare now identical.Both methods return
self.peer_count().await < TARGET_PEERS. Previously they used different thresholds (MIN_PEERSvsMAX_PEERS), giving the system hysteresis. With a single constant, they are functionally duplicates. This is fine if you want distinct semantic names at call sites, but worth noting that there's no longer any gap between "we need more" and "we're at capacity."
With `MIN_PEERS=1` used as a "should we connect more peers" check, we ended up not trying to connect more peers in the maintenance loop which leads to getting stuck with 1 peer only after initial peers are gone. Remove `MIN_PEERS` and `MAX_PEERS` and use `TARGET_PEERS` as the only peer count constant.
175be1e to
02180a0
Compare
With
MIN_PEERS=1used as a "should we connect more peers" check, we ended up not trying to connect more peers in the maintenance loop which leads to getting stuck with 1 peer only after initial peers are gone.Remove
MIN_PEERSandMAX_PEERSand useTARGET_PEERSas the only peer count constant.Summary by CodeRabbit
Refactor
Behavioral change
Tests