feat: dispatch progress callback on registration#473
feat: dispatch progress callback on registration#473xdustinface wants to merge 1 commit intov0.42-devfrom
Conversation
📝 WalkthroughWalkthroughThe progress callback mechanism in the FFI client is enhanced to synchronously dispatch the current progress state immediately when a callback is registered, instead of only storing the callback for future updates. A corresponding test validates this new behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 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 |
e9a5a6b to
24a4b41
Compare
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
486d505 to
5a92aab
Compare
24a4b41 to
8f1263d
Compare
Send the current sync progress to a newly registered callback immediately on registration, so callers don't have to wait for the next progress update to get the current state.
8f1263d to
544f28d
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
dash-spv-ffi/tests/test_client.rs (1)
91-98: Minor:assert!inextern "C"can be UB if called from actual C code.Panicking across an FFI boundary is undefined behavior. Since this callback is only invoked from Rust test code (via
cb.dispatch()), it's safe here. However, if this pattern were copied to production code or the callback were invoked from C, consider replacing with a null check that sets an error flag instead of panicking.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@dash-spv-ffi/tests/test_client.rs` around lines 91 - 98, The extern "C" callback test_progress_callback currently uses assert!(!progress.is_null()) which can panic across an FFI boundary; change it to perform an explicit null check instead of asserting: inside test_progress_callback, check if progress.is_null(), and if so record an error/invalid-pointer state on the ProgressCallbackData (e.g., set a dedicated error or invalid flag stored in data) and return early; otherwise safely dereference progress (as with FFISyncProgress) and continue updating data.state and data.is_synced. Ensure you reference the test_progress_callback, FFISyncProgress, and ProgressCallbackData symbols when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@dash-spv-ffi/tests/test_client.rs`:
- Around line 91-98: The extern "C" callback test_progress_callback currently
uses assert!(!progress.is_null()) which can panic across an FFI boundary; change
it to perform an explicit null check instead of asserting: inside
test_progress_callback, check if progress.is_null(), and if so record an
error/invalid-pointer state on the ProgressCallbackData (e.g., set a dedicated
error or invalid flag stored in data) and return early; otherwise safely
dereference progress (as with FFISyncProgress) and continue updating data.state
and data.is_synced. Ensure you reference the test_progress_callback,
FFISyncProgress, and ProgressCallbackData symbols when making the change.
Send the current sync progress to a newly registered callback immediately on registration, so callers don't have to wait for the next progress update to get the current state.
Based on:
_TestCallbackData#472Summary by CodeRabbit
Bug Fixes
Tests