Skip to content

Commit 7526ebe

Browse files
refactor: improve filter sync locking mechanism
- Updated the locking logic in the filter synchronization process to clone the `received_filter_heights` before awaiting the mutex, ensuring the `RwLock` is released promptly. - This change enhances concurrency and responsiveness during filter sync operations, aligning with recent async improvements in the codebase.
1 parent c4008fd commit 7526ebe

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

dash-spv/src/sync/filters.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2842,7 +2842,9 @@ impl<S: StorageManager + Send + Sync + 'static, N: NetworkManager + Send + Sync
28422842
stats_lock.filter_sync_start_time = Some(std::time::Instant::now());
28432843
stats_lock.last_filter_received_time = None;
28442844
// Clear the received heights tracking for a fresh start
2845-
let mut heights = stats_lock.received_filter_heights.lock().await;
2845+
let received_filter_heights = stats_lock.received_filter_heights.clone();
2846+
drop(stats_lock); // Release the RwLock before awaiting the mutex
2847+
let mut heights = received_filter_heights.lock().await;
28462848
heights.clear();
28472849
tracing::info!(
28482850
"📊 Started new filter sync tracking: {} filters requested",

0 commit comments

Comments
 (0)