Skip to content

Comments

refactor: move manager initialization from trait method to constructors #467

Draft
xdustinface wants to merge 4 commits intov0.42-devfrom
refactor/move-initialization
Draft

refactor: move manager initialization from trait method to constructors #467
xdustinface wants to merge 4 commits intov0.42-devfrom
refactor/move-initialization

Conversation

@xdustinface
Copy link
Collaborator

  • Moves initialization logic out of the SyncManager::initialize() trait method and into each manager's constructor.
  • Genesis block is now stored before managers are created, so they can read the tip during construction.
  • The SyncCoordinator seeds initial progress from actual manager state instead of default and uses WatchStream::from_changes to avoid re-emitting all initial progresses.

Based on:

commit a138810
Author: xdustinface <xdustinfacex@gmail.com>
Date:   Thu Feb 12 20:03:27 2026 +0100

    feat: report/propagate client start/run failures

    We currently just silently ignore any failure inside the sync coordinator or `monitor_network` thread. This PR propagates them and also adds a FFI callback structure which can be set to receive notifications about errors inside the SPV client.

commit dfb0355
Author: xdustinface <xdustinfacex@gmail.com>
Date:   Wed Feb 18 20:42:01 2026 +0100

    refactor: cleanup `DashSpvClient` to have single `run()` entry point

    Combine `start()` + `monitor_network()` + `stop()` into a single `run(token)` entry
    point. Callers no longer need to call `start()` separately since `run()` handles
    the full lifecycle and returns after the token is cancelled.

    - Make `start()` an internal function
    - Remove `monitor_network()` its loop is now inside `run()`
    - Remove `dash_spv_ffi_client_start` so that `dash_spv_ffi_client_run` is the only FFI entry point
    - Move ctrl-c handling out of the client
commit 1d16871
Author: xdustinface <xdustinfacex@gmail.com>
Date:   Sat Feb 21 13:34:13 2026 +0100

    refactor: remove `SyncState::Initializing` variant

    The `Initializing` state was only used as a default before
    `initialize()` was called. Replace it with `WaitForEvents` as the
    default state to simplify the state machine.
commit 4220038
Author: xdustinface <xdustinfacex@gmail.com>
Date:   Sat Feb 21 14:04:22 2026 +0100

    refactor: add `ensure_not_started()` guard

    Add a state guard that returns an error if a manager's sync
    has already been started, and use it in `start_sync()` implementations
    instead of inline state checks.
- Moves initialization logic out of the `SyncManager::initialize()` trait method and into each manager's constructor.
- Genesis block is now stored before managers are created, so they can read the tip during construction.
- The `SyncCoordinator` seeds initial progress from actual manager state instead of default and uses `WatchStream::from_changes` to avoid re-emitting all initial progresses.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/move-initialization

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

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.

1 participant