Skip to content
Open
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
8 changes: 8 additions & 0 deletions src/context/connection_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,14 @@ impl ConnectionStatus {
}
}
CoreBackendMode::Rpc => {
// Clear stale SPV state that may linger if the backend mode
// switched from SPV to RPC without a full `reset()`.
self.spv_connected_peers.store(0, Ordering::Relaxed);
*self
.spv_no_peers_since
.lock()
.unwrap_or_else(|e| e.into_inner()) = None;
Comment on lines +462 to +468
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Reset spv_status in RPC branch to prevent stale fast-refresh cadence.

At Line [444]-Line [450], peer-related SPV fields are cleared, but spv_status is not. Since Line [394] uses spv_status == Stopping to force a 200ms refresh interval, switching to RPC during SPV shutdown can leave RPC polling stuck at the fast cadence and spam GetBestChainLocks.

Proposed minimal fix
             CoreBackendMode::Rpc => {
                 // Clear stale SPV state that may linger if the backend mode
                 // switched from SPV to RPC without a full `reset()`.
+                self.set_spv_status(SpvStatus::Idle);
                 self.spv_connected_peers.store(0, Ordering::Relaxed);
                 *self
                     .spv_no_peers_since
                     .lock()
                     .unwrap_or_else(|e| e.into_inner()) = None;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/context/connection_status.rs` around lines 444 - 450, Reset the SPV
status in the same RPC-branch cleanup where you clear spv_connected_peers and
spv_no_peers_since: set self.spv_status to a non-Stopping state (e.g.,
SpvStatus::Stopped or the equivalent default) so that code checking `spv_status
== Stopping` (used to enforce the 200ms fast refresh) won't remain true after
switching to RPC; update the same block that touches spv_connected_peers and
spv_no_peers_since to also update spv_status via the same atomic/mutex accessors
used elsewhere.

Comment on lines 461 to +468
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🟡 Suggestion: RPC cleanup doesn't reset spv_status — stale Stopping state affects poll cadence

The new RPC branch clears spv_connected_peers and spv_no_peers_since, but doesn't reset spv_status. After stop_spv() sets status to Stopping, trigger_refresh() continues using the 200ms shutdown poll cadence instead of the normal 5s interval. Also, spv_last_error is not cleared, which reset() does handle (lines 99-100, 113-114).

Consider adding self.spv_status = SpvStatus::Idle; and self.spv_last_error = None; to match the full cleanup that reset() performs.

source: ['codex-general', 'claude-general']

🤖 Fix this with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/context/connection_status.rs`:
- [SUGGESTION] lines 461-468: RPC cleanup doesn't reset spv_status — stale Stopping state affects poll cadence
  The new RPC branch clears `spv_connected_peers` and `spv_no_peers_since`, but doesn't reset `spv_status`. After `stop_spv()` sets status to `Stopping`, `trigger_refresh()` continues using the 200ms shutdown poll cadence instead of the normal 5s interval. Also, `spv_last_error` is not cleared, which `reset()` does handle (lines 99-100, 113-114).

Consider adding `self.spv_status = SpvStatus::Idle;` and `self.spv_last_error = None;` to match the full cleanup that `reset()` performs.


// Update ZMQ status if there's a new event
let disable_zmq = app_context
.get_settings()
Expand Down
Loading