Skip to content

feat: dispatch progress callback on registration - #473

Merged
xdustinface merged 1 commit into
v0.42-devfrom
feat/initial-progress
Feb 27, 2026
Merged

xdustinface merged 1 commit into
v0.42-devfrom
feat/initial-progress

Conversation

@xdustinface

@xdustinface xdustinface commented Feb 25, 2026 •

Copy link
Copy Markdown
Collaborator

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:

Summary by CodeRabbit

  • Bug Fixes

    • Progress callbacks now synchronously retrieve and immediately dispatch the current progress state when registered, ensuring callbacks are invoked with up-to-date status information upon registration.
  • Tests

    • Added comprehensive test coverage for progress callback registration and initial state emission verification.

@coderabbitai

coderabbitai Bot commented Feb 25, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@xdustinface has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 1 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 544f28d and f0c5e89.

📒 Files selected for processing (2)
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/tests/test_client.rs
📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Progress Callback Enhancement
dash-spv-ffi/src/client.rs
Modified dash_spv_ffi_client_set_progress_callback to retrieve and immediately dispatch current progress to the callback upon registration, rather than only storing the callback for future updates.
Progress Callback Tests
dash-spv-ffi/tests/test_client.rs
Added FFI test scaffolding including ProgressCallbackData helper struct, test_progress_callback extern "C" function, and test_set_progress_callback_emits_progress test to verify callback behavior and initial progress state delivery.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Hops with glee, a callback so neat!
When progress is set, dispatch is fleet—
No waiting around for future ticks,
Just grab the state and do the tricks! ✨

🚥 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 'feat: dispatch progress callback on registration' directly and clearly describes the main change: immediately dispatching progress to a newly registered callback.
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 unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/initial-progress

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 force-pushed the feat/initial-progress branch 2 times, most recently from e9a5a6b to 24a4b41 Compare February 25, 2026 08:15
@github-actions github-actions Bot added the merge-conflict The PR conflicts with the target branch. label Feb 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@xdustinface
xdustinface force-pushed the chore/drop-test-callback-data branch from 486d505 to 5a92aab Compare February 25, 2026 08:16
Base automatically changed from chore/drop-test-callback-data to v0.42-dev February 26, 2026 15:57
@xdustinface
xdustinface force-pushed the feat/initial-progress branch from 24a4b41 to 8f1263d Compare February 26, 2026 16:39
@github-actions github-actions Bot removed the merge-conflict The PR conflicts with the target branch. label Feb 26, 2026
@xdustinface
xdustinface force-pushed the feat/initial-progress branch from 8f1263d to 544f28d Compare February 26, 2026 16:43
@xdustinface
xdustinface marked this pull request as ready for review February 26, 2026 16:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
dash-spv-ffi/tests/test_client.rs (1)

91-98: Minor: assert! in extern "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.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 77840c9 and 544f28d.

📒 Files selected for processing (2)
  • dash-spv-ffi/src/client.rs
  • dash-spv-ffi/tests/test_client.rs

@xdustinface
xdustinface marked this pull request as draft February 27, 2026 05:52
@xdustinface xdustinface reopened this Feb 27, 2026
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.
@xdustinface
xdustinface force-pushed the feat/initial-progress branch from 544f28d to f0c5e89 Compare February 27, 2026 17:49
@xdustinface
xdustinface marked this pull request as ready for review February 27, 2026 17:50
@xdustinface
xdustinface requested a review from ZocoLini February 27, 2026 17:56
@xdustinface
xdustinface merged commit 7ddf6a6 into v0.42-dev Feb 27, 2026
52 checks passed
@xdustinface
xdustinface deleted the feat/initial-progress branch February 27, 2026 18:25
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