Skip to content

refactor: add clear_in_flight_state() to SyncManager trait#484

Merged
xdustinface merged 1 commit intov0.42-devfrom
chore/clear-inflight-on-disconnect
Feb 28, 2026
Merged

refactor: add clear_in_flight_state() to SyncManager trait#484
xdustinface merged 1 commit intov0.42-devfrom
chore/clear-inflight-on-disconnect

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Feb 27, 2026

Add a required clear_in_flight_state() method to the SyncManager trait and implement it for all managers. This gets called by the default stop_sync() implementation to force every manager to handle disconnect cleanup.

Summary by CodeRabbit

  • Refactor

    • Enhanced synchronization state management by introducing a unified mechanism for clearing in-flight state across block headers, blocks, filters, chain locks, and instant send operations. Improved consistency and reliability of sync state resets during network operations.
  • Chores

    • Internal structural improvements to sync manager implementations for better code maintainability.

Add a required `clear_in_flight_state()` method to the `SyncManager` trait
and implement it for all managers. This gets called by the default `stop_sync()` implementation to force
every manager to handle disconnect cleanup.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ddf6a6 and 210db5d.

📒 Files selected for processing (13)
  • dash-spv/src/sync/block_headers/pipeline.rs
  • dash-spv/src/sync/block_headers/sync_manager.rs
  • dash-spv/src/sync/blocks/sync_manager.rs
  • dash-spv/src/sync/chainlock/manager.rs
  • dash-spv/src/sync/chainlock/sync_manager.rs
  • dash-spv/src/sync/filter_headers/manager.rs
  • dash-spv/src/sync/filter_headers/sync_manager.rs
  • dash-spv/src/sync/filters/manager.rs
  • dash-spv/src/sync/filters/sync_manager.rs
  • dash-spv/src/sync/instantsend/manager.rs
  • dash-spv/src/sync/instantsend/sync_manager.rs
  • dash-spv/src/sync/masternodes/sync_manager.rs
  • dash-spv/src/sync/sync_manager.rs

📝 Walkthrough

Walkthrough

A new clear_in_flight_state() method is added to the SyncManager trait, implemented across multiple sync managers (BlockHeaders, Blocks, ChainLock, FilterHeaders, Filters, InstantSend, Masternodes) to reset in-flight state. The stop_sync() method now invokes this new method. Several manager fields are exposed with pub(super) visibility for parent module access.

Changes

Cohort / File(s) Summary
SyncManager Trait
dash-spv/src/sync/sync_manager.rs
Added clear_in_flight_state(&mut self) trait method. Updated stop_sync() to call clear_in_flight_state(). Implemented in MockManager.
BlockHeaders Sync
dash-spv/src/sync/block_headers/pipeline.rs, dash-spv/src/sync/block_headers/sync_manager.rs
Added public accessor checkpoint_manager() on HeadersPipeline. Implemented clear_in_flight_state() to reset pipeline state and clear pending announcements.
Blocks Sync
dash-spv/src/sync/blocks/sync_manager.rs
Replaced stop_sync() with clear_in_flight_state(), reinitializing pipeline and resetting filters_sync_complete flag.
ChainLock Sync
dash-spv/src/sync/chainlock/manager.rs, dash-spv/src/sync/chainlock/sync_manager.rs
Exposed masternode_ready field with pub(super) visibility. Implemented clear_in_flight_state() to clear requested chainlocks and reset retry state.
FilterHeaders Sync
dash-spv/src/sync/filter_headers/manager.rs, dash-spv/src/sync/filter_headers/sync_manager.rs
Exposed checkpoint_start_height field with pub(super) visibility. Implemented clear_in_flight_state() to reset pipeline and checkpoint state.
Filters Sync
dash-spv/src/sync/filters/manager.rs, dash-spv/src/sync/filters/sync_manager.rs
Exposed pending_batches and filters_matched fields with pub(super) visibility. Removed clear_in_flight_state() from manager. Replaced stop_sync() with clear_in_flight_state() in sync manager implementation.
InstantSend Sync
dash-spv/src/sync/instantsend/manager.rs, dash-spv/src/sync/instantsend/sync_manager.rs
Exposed PendingInstantLock type and pending_instantlocks field with pub(super) visibility. Implemented clear_in_flight_state() to clear pending locks.
Masternodes Sync
dash-spv/src/sync/masternodes/sync_manager.rs
Implemented clear_in_flight_state() to clear pending requests and reset retry counters.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 With whiskers twitching in delight,
We clear the in-flight state just right,
Each manager knows how to reset,
Through trait-based patterns, we're truly blessed!
The pipeline flows, no more delay,
Clean sync magic saves the day!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding a new clear_in_flight_state() method to the SyncManager trait, which is the primary objective implemented across the entire changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/clear-inflight-on-disconnect

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@xdustinface xdustinface requested a review from ZocoLini February 27, 2026 18:52
@xdustinface xdustinface merged commit 2824e52 into v0.42-dev Feb 28, 2026
53 checks passed
@xdustinface xdustinface deleted the chore/clear-inflight-on-disconnect branch February 28, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants