Skip to content

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Jan 15, 2026

It's basically doing nothing except logging some things.

Based on:

Summary by CodeRabbit

Release Notes

  • Refactor

    • Removed synchronous sync_to_tip() and start_sync() public methods. Synchronization is now asynchronous via the run() method with cancellation token support.
  • Documentation

    • Updated examples and API documentation to reflect the new asynchronous synchronization pattern.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

This PR removes the sync_to_tip and start_sync public APIs from both the FFI bindings and Rust client library, along with all related implementation code, tests, examples, and documentation. The synchronization pattern is being replaced with an asynchronous run loop approach.

Changes

Cohort / File(s) Summary
FFI Documentation
dash-spv-ffi/FFI_API.md, dash-spv-ffi/FFI_DOCS_README.md, dash-spv-ffi/README.md
Removed dash_spv_ffi_client_sync_to_tip from API documentation, function tables, and usage examples; reduced Synchronization function count from 7 to 6.
FFI Header Declaration
dash-spv-ffi/include/dash_spv_ffi.h
Removed public FFI function declaration dash_spv_ffi_client_sync_to_tip (29 lines).
FFI Implementation
dash-spv-ffi/src/client.rs
Removed CallbackInfo::Simple enum variant, dash_spv_ffi_client_sync_to_tip function, and associated callback handling; removed sync_to_tip invocation from dash_spv_ffi_client_test_sync.
FFI Documentation Generator
dash-spv-ffi/scripts/generate_ffi_docs.py
Removed Markdown generation for the "Sync to chain tip" documentation block.
FFI Tests
dash-spv-ffi/tests/c_tests/test_advanced.c, dash-spv-ffi/tests/integration/test_full_workflow.rs, dash-spv-ffi/tests/test_event_callbacks.rs, dash-spv-ffi/tests/unit/test_async_operations.rs, dash-spv-ffi/tests/unit/test_client_lifecycle.rs
Removed all invocations of dash_spv_ffi_client_sync_to_tip, callback setup blocks, and sync-related test assertions.
Rust Library API
dash-spv/src/client/lifecycle.rs, dash-spv/src/client/sync_coordinator.rs
Removed public methods start_sync() and sync_to_tip(); eliminated pre-fetch synchronization pattern.
Rust Library Examples & Entry Point
dash-spv/README.md, dash-spv/examples/filter_sync.rs, dash-spv/examples/simple_sync.rs, dash-spv/examples/spv_with_wallet.rs, dash-spv/src/main.rs
Removed sync_to_tip calls; replaced synchronous sync-then-stop pattern with asynchronous run(command_receiver, shutdown_token) pattern. Updated documentation examples to use command channels and cancellation tokens.
Rust Library Core
dash-spv/src/lib.rs
Added CancellationToken import; updated crate documentation example to reflect new run-based workflow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • feat: Introduce DashSpvClientInterface #214: Modifies DashSpvClient sync/monitor API—removes sync_to_tip entry point and introduces run with command-receiver/cancellation-token flow affecting the same core functions and files.

Suggested reviewers

  • pauldelucia

Poem

🐰 The sync-to-tip hops away,

Replaced by run's asynchronous way,

Channels and tokens now guide the dance,

Simpler flows, a cleaner advance! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: drop DashSpvClient.sync_to_tip' directly and clearly describes the main change: removal of the sync_to_tip method from DashSpvClient across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

Base automatically changed from chore/drop-integration-tests to v0.42-dev January 16, 2026 14:53
It's basically doing nothing except logging some things.
@xdustinface xdustinface force-pushed the refactor/rename-sync-to-tip branch from 084f124 to b19bd7d Compare January 16, 2026 23:03
@xdustinface xdustinface marked this pull request as ready for review January 16, 2026 23:22
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
dash-spv/README.md (1)

52-69: Add the CancellationToken import so the example compiles.

The README snippet uses CancellationToken without importing it. All examples and implementations in the codebase import it from tokio_util::sync, which is a direct dependency.

🩹 Proposed doc fix
 use dash_spv::{ClientConfig, DashSpvClient};
+use tokio_util::sync::CancellationToken;
dash-spv-ffi/src/client.rs (1)

569-575: Pre-existing bug: early return leaks the client from the guard.

If the first sync_progress() call fails (lines 571-574), the function returns without restoring spv_client to the guard. This leaves inner holding None, causing subsequent operations to fail with "Client not initialized". Compare with lines 586-588 which correctly restore the client before returning.

Proposed fix
         let start_height = match spv_client.sync_progress().await {
             Ok(progress) => progress.header_height,
             Err(e) => {
                 tracing::error!("Failed to get initial height: {}", e);
+                let mut guard = client.inner.lock().unwrap();
+                *guard = Some(spv_client);
                 return Err(e);
             }
         };
🧹 Nitpick comments (1)
dash-spv-ffi/src/client.rs (1)

40-47: Consider simplifying CallbackInfo enum.

After removing the Simple variant, CallbackInfo now has only one variant (Detailed). While keeping it as an enum provides flexibility for future additions, you could simplify to a struct if no other variants are planned.

Copy link
Collaborator

@ZocoLini ZocoLini left a comment

Choose a reason for hiding this comment

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

FR i have never checked this method body before, definitely not the behavior i expected from a method with such name

@xdustinface xdustinface merged commit a78ed5b into v0.42-dev Jan 17, 2026
53 checks passed
@xdustinface xdustinface deleted the refactor/rename-sync-to-tip branch January 17, 2026 01:44
@xdustinface xdustinface changed the title refactor: drop DashSpvClient.sync_to_tip refactor: drop useless DashSpvClient.sync_to_tip Jan 17, 2026
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.

3 participants