From ab063619a8eaf30fb73a290ef8e593145dd8a8c5 Mon Sep 17 00:00:00 2001 From: xdustinface Date: Tue, 17 Feb 2026 16:04:03 +0100 Subject: [PATCH] fix: correct state transitions in filter sync manager Move `set_state(Syncing)` after the early returns in `start_download()` so the manager stays in the correct state when filter headers haven't reached the needed height. Return to `WaitForEvents` in that case so new `FilterHeadersStored` events re-trigger `start_download` with proper batch processing initialization. Also transition `Synced` back to `Syncing` in `handle_new_filter_headers` when new filter headers arrive, ensuring `is_synced()` returns false until all new filters and matched blocks are fully processed. --- dash-spv/src/sync/filters/manager.rs | 91 ++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 4 deletions(-) diff --git a/dash-spv/src/sync/filters/manager.rs b/dash-spv/src/sync/filters/manager.rs index f91bdeeba..50969a9f5 100644 --- a/dash-spv/src/sync/filters/manager.rs +++ b/dash-spv/src/sync/filters/manager.rs @@ -149,7 +149,6 @@ impl SyncResult> { debug_assert!(self.is_idle(), "manager should have no in-flight state on start"); - self.set_state(SyncState::Syncing); // Use filter_committed_height for restart recovery instead of // synced_height, which advances per-block and may exceed committed scan progress. let (wallet_birth_height, wallet_committed_height) = { @@ -184,7 +183,10 @@ impl { + // Transition back to Syncing so is_synced() returns false + // until all new filters and matched blocks are fully processed. + if self.state() == SyncState::Synced { + self.set_state(SyncState::Syncing); + } + self.filter_pipeline.extend_target(tip_height); { let header_storage = self.header_storage.read().await; self.filter_pipeline.send_pending(requests, &*header_storage).await?; } - if self.state() == SyncState::Synced && self.active_batches.is_empty() { + if self.active_batches.is_empty() { tracing::debug!("Processing new filter (target: {})", tip_height); return self.try_create_lookahead_batches().await; } @@ -755,13 +765,14 @@ impl