feat: react to network events in maintenance loop#433
Conversation
📝 WalkthroughWalkthroughThe maintenance loop now subscribes to network events, logging received events, resetting DNS discovery timers, and triggering immediate maintenance checks. This adds a reactive event-driven pathway to the previously timer-based maintenance loop. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
1d9fe8e to
0a40638
Compare
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
Subscribe to network events so the maintenance loop wakes immediately on peer connect/disconnect to reset the DNS timer and to try to connect to known addresses.
3afc1a5 to
ec3ab31
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@dash-spv/src/network/manager.rs`:
- Line 887: Replace the inconsistent tracing::error! call with log::error! to
match the rest of the file's logging macros; update the occurrence in the
network event handling (the line currently emitting "Network event error: {}"
using tracing::error!) to use log::error! instead so it aligns with other calls
like log::debug!, log::info!, log::warn!, and log::error! throughout manager.rs.
- Around line 879-891: The maintenance loop currently treats any
broadcast::RecvError as fatal; instead, in the event handling branch where
network_events.recv() returns Err(error) match on the RecvError: if it's
RecvError::Lagged(n) log a warning/debug including n, skip breaking (continue
the loop) and allow dns_interval.reset() and this.maintenance_tick() to keep
running; if it's RecvError::Closed then log an error and break the loop. Update
the Err(error) arm to pattern-match RecvError::Lagged and RecvError::Closed
accordingly around network_events.recv(), keeping calls to dns_interval.reset()
and this.maintenance_tick() in the Ok(event) path.
|
Addressed the two review items from CodeRabbit in #448:
|
Subscribe to network events so the maintenance loop wakes immediately on peer connect/disconnect to reset the DNS
timer and to try to connect to known addresses.
Based on:
Summary by CodeRabbit