feat: add cycle to SyncEvent::SyncComplete#459
Conversation
Emit `SyncComplete` on every not-synced to synced transition instead of only once, with a cycle field (0 = initial, 1+ = incremental) so consumers can distinguish sync phases. Duration logging measures per-cycle time instead of time since client start.
📝 WalkthroughWalkthroughA Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@dash-spv-ffi/tests/unit/test_async_operations.rs`:
- Around line 272-275: The integration test defines unused callbacks
on_sync_progress and on_sync_complete whose signatures don't match the official
OnSyncProgressCallback/OnSyncCompleteCallback (see callbacks.rs) and are never
registered via dash_spv_ffi_client_set_sync_event_callbacks; either remove these
unused functions from dash-spv-ffi/tests/integration/test_full_workflow.rs or
update their signatures to match the official callback types (and then pass them
into dash_spv_ffi_client_set_sync_event_callbacks so they are actually
registered), ensuring the function names (on_sync_progress, on_sync_complete)
and registration call match the FFI types used in callbacks.rs.
| extern "C" fn on_sync_complete(_header_tip: u32, _cycle: u32, user_data: *mut c_void) { | ||
| let data = unsafe { &*(user_data as *const EventData) }; | ||
| data.sync_complete.store(true, Ordering::SeqCst); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
rg -n 'on_sync_complete' --type=rs -C 8 dash-spv-ffi/tests/Repository: dashpay/rust-dashcore
Length of output: 91
🏁 Script executed:
rg -n 'on_sync_complete' --type rust -C 8 dash-spv-ffi/tests/Repository: dashpay/rust-dashcore
Length of output: 5172
🏁 Script executed:
rg -n 'OnSyncCompleteCallback|on_sync_complete.*=' --type rust -C 3 dash-spv-ffi/Repository: dashpay/rust-dashcore
Length of output: 1121
🏁 Script executed:
rg -n 'FFISyncEventCallbacks' --type rust -C 5 dash-spv-ffi/tests/integration/test_full_workflow.rsRepository: dashpay/rust-dashcore
Length of output: 47
🏁 Script executed:
rg -n 'extern "C" fn' --type rust -C 2 dash-spv-ffi/tests/integration/test_full_workflow.rs | head -60Repository: dashpay/rust-dashcore
Length of output: 643
🏁 Script executed:
rg -n 'on_sync_progress\|on_sync_complete' --type rust -B 30 dash-spv-ffi/tests/integration/test_full_workflow.rs | grep -A 30 "struct\|FFI" | head -80Repository: dashpay/rust-dashcore
Length of output: 47
🏁 Script executed:
sed -n '60,150p' dash-spv-ffi/tests/integration/test_full_workflow.rsRepository: dashpay/rust-dashcore
Length of output: 3536
🏁 Script executed:
rg -n 'dash_spv_ffi_client_set_sync_event_callbacks\|on_sync' --type rust dash-spv-ffi/tests/integration/test_full_workflow.rsRepository: dashpay/rust-dashcore
Length of output: 47
🏁 Script executed:
sed -n '1,200p' dash-spv-ffi/tests/integration/test_full_workflow.rs | grep -n 'on_sync_progress\|on_sync_complete\|set_sync_event'Repository: dashpay/rust-dashcore
Length of output: 280
🏁 Script executed:
rg -n 'dash_spv_ffi' --type rust dash-spv-ffi/tests/integration/test_full_workflow.rs | grep -i 'callback\|event'Repository: dashpay/rust-dashcore
Length of output: 47
🏁 Script executed:
wc -l dash-spv-ffi/tests/integration/test_full_workflow.rs && sed -n '90,200p' dash-spv-ffi/tests/integration/test_full_workflow.rsRepository: dashpay/rust-dashcore
Length of output: 4179
Unit test callback signature is correct; integration test has unused callbacks with incompatible signature.
The unit test correctly implements on_sync_complete(_header_tip: u32, _cycle: u32, user_data: *mut c_void) matching the official OnSyncCompleteCallback type defined in callbacks.rs:212.
However, the integration test in dash-spv-ffi/tests/integration/test_full_workflow.rs (lines 71, 83) defines callbacks with an incompatible signature:
on_sync_progress(progress: f64, msg: *const c_char, user_data: *mut c_void)on_sync_complete(success: bool, error: *const c_char, user_data: *mut c_void)
These callbacks are never used—they're defined but never passed to dash_spv_ffi_client_set_sync_event_callbacks or any other FFI function. Remove these unused callbacks or update them to match the official callback types and properly register them.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@dash-spv-ffi/tests/unit/test_async_operations.rs` around lines 272 - 275, The
integration test defines unused callbacks on_sync_progress and on_sync_complete
whose signatures don't match the official
OnSyncProgressCallback/OnSyncCompleteCallback (see callbacks.rs) and are never
registered via dash_spv_ffi_client_set_sync_event_callbacks; either remove these
unused functions from dash-spv-ffi/tests/integration/test_full_workflow.rs or
update their signatures to match the official callback types (and then pass them
into dash_spv_ffi_client_set_sync_event_callbacks so they are actually
registered), ensuring the function names (on_sync_progress, on_sync_complete)
and registration call match the FFI types used in callbacks.rs.
Emit
SyncCompleteon every not-synced to synced transition instead of only once, with a cycle field (0 = initial, 1+ = incremental) so consumers can distinguish sync phases. Duration logging measures per-cycle time instead of time since client start.Summary by CodeRabbit
Release Notes