-
Notifications
You must be signed in to change notification settings - Fork 10
fix: sync progress #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: sync progress #150
Conversation
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (9)
🧰 Additional context used📓 Path-based instructions (11)dash-spv/**/*.rs📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)
Files:
**/*.rs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/src/**/*.rs📄 CodeRabbit inference engine (AGENTS.md)
Files:
dash-spv-ffi/include/dash_spv_ffi.h📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)
Files:
{dash-network-ffi,dash-spv-ffi,key-wallet-ffi,swift-dash-core-sdk}/**/*.{rs,c,h,swift}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
*-ffi/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
swift-dash-core-sdk/Sources/**/*.swift📄 CodeRabbit inference engine (swift-dash-core-sdk/CLAUDE.md)
Files:
{key-wallet,swift-dash-core-sdk}/**/*.{rs,swift}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
swift-dash-core-sdk/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
dash-spv-ffi/src/**/*.rs📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)
Files:
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h📄 CodeRabbit inference engine (swift-dash-core-sdk/CLAUDE.md)
Files:
🧠 Learnings (13)📚 Learning: 2025-08-16T04:14:07.718ZApplied to files:
📚 Learning: 2025-08-16T04:15:29.335ZApplied to files:
📚 Learning: 2025-08-25T17:15:59.361ZApplied to files:
📚 Learning: 2025-08-16T04:15:57.225ZApplied to files:
📚 Learning: 2025-08-16T04:15:57.225ZApplied to files:
📚 Learning: 2025-08-16T04:14:07.718ZApplied to files:
📚 Learning: 2025-08-16T04:14:07.718ZApplied to files:
📚 Learning: 2025-08-16T04:14:07.718ZApplied to files:
📚 Learning: 2025-06-26T15:49:53.811ZApplied to files:
📚 Learning: 2025-06-26T15:48:36.342ZApplied to files:
📚 Learning: 2025-08-29T04:01:18.111ZApplied to files:
📚 Learning: 2025-08-16T04:14:07.718ZApplied to files:
📚 Learning: 2025-08-16T04:15:29.335ZApplied to files:
🧬 Code graph analysis (3)swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swift (3)
dash-spv/src/client/mod.rs (5)
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
🔇 Additional comments (45)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (1)
64-64: Consider documenting the worker_threads field.The new
worker_threadsfield inFFIClientConfiglacks documentation. Consider adding a comment explaining that it controls the number of Tokio runtime worker threads (with 0 meaning auto-detect).typedef struct FFIClientConfig { void *inner; + /// Number of Tokio worker threads (0 = auto) uint32_t worker_threads; - } FFIClientConfig;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
dash-spv-ffi/dash_spv_ffi.h(1 hunks)dash-spv-ffi/include/dash_spv_ffi.h(1 hunks)dash-spv-ffi/src/bin/ffi_cli.rs(1 hunks)dash-spv-ffi/src/types.rs(3 hunks)dash-spv/src/client/mod.rs(1 hunks)dash-spv/src/types.rs(2 hunks)swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h(5 hunks)swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift(4 hunks)swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swift(5 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
dash-spv-ffi/src/**/*.rs
📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)
dash-spv-ffi/src/**/*.rs: FFI functions must be declared with #[no_mangle] extern "C"
Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)
Provide corresponding _destroy() functions for all FFI-owned types to enforce explicit memory management
Return Rust strings to C as *const c_char; allocate so the caller can free with dash_string_free
Accept input strings from C as *const c_char (borrowed; do not free inputs)
Functions returning pointers transfer ownership to the caller; functions taking pointers only borrow
Add cbindgen annotations for complex types so headers are generated correctly
Files:
dash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/src/types.rs
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Use proper error types with thiserror and propagate errors appropriately
Use the tokio runtime for async operations in Rust
Use conditional compilation feature flags for optional features (#[cfg(feature = ...)])
Format Rust code with cargo fmt (and enforce via cargo fmt --check)
Run clippy with -D warnings and fix all lints
Adhere to MSRV Rust 1.89 (avoid features requiring newer compiler)
**/*.rs: Format Rust code with rustfmt (per rustfmt.toml); run cargo fmt --all before commits
Lint with clippy; treat warnings as errors in CI
Follow Rust naming: snake_case for functions/variables, UpperCamelCase for types/traits, SCREAMING_SNAKE_CASE for consts
Prefer async using tokio where applicable
Files:
dash-spv-ffi/src/bin/ffi_cli.rsdash-spv/src/client/mod.rsdash-spv-ffi/src/types.rsdash-spv/src/types.rs
{dash-network-ffi,dash-spv-ffi,key-wallet-ffi,swift-dash-core-sdk}/**/*.{rs,c,h,swift}
📄 CodeRabbit inference engine (CLAUDE.md)
Be careful with memory management at FFI boundaries (C/Swift interop)
Files:
dash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/src/types.rsswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swiftdash-spv-ffi/include/dash_spv_ffi.hdash-spv-ffi/dash_spv_ffi.hswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swiftswift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
**/src/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/src/**/*.rs: Each crate keeps sources in src/
Avoid unwrap()/expect() in library code; use proper error types (e.g., thiserror)
Place unit tests alongside code with #[cfg(test)]
Files:
dash-spv-ffi/src/bin/ffi_cli.rsdash-spv/src/client/mod.rsdash-spv-ffi/src/types.rsdash-spv/src/types.rs
*-ffi/**
📄 CodeRabbit inference engine (AGENTS.md)
FFI bindings live in *-ffi crates
Files:
dash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/src/types.rsdash-spv-ffi/include/dash_spv_ffi.hdash-spv-ffi/dash_spv_ffi.h
dash-spv/**/*.rs
📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)
dash-spv/**/*.rs: Enforce Rust formatting viacargo fmt --checkon all Rust source files
All code must be clippy-clean: runcargo clippy --all-targets --all-features -- -D warnings
Files:
dash-spv/src/client/mod.rsdash-spv/src/types.rs
swift-dash-core-sdk/Sources/**/*.swift
📄 CodeRabbit inference engine (swift-dash-core-sdk/CLAUDE.md)
swift-dash-core-sdk/Sources/**/*.swift: Use actors for state management to maintain thread safety in SDK components
Use @available checks for features that require newer OS versions (e.g., SwiftData on iOS 17+)
Files:
swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swiftswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift
{key-wallet,swift-dash-core-sdk}/**/*.{rs,swift}
📄 CodeRabbit inference engine (CLAUDE.md)
Never log or expose private keys
Files:
swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swiftswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift
swift-dash-core-sdk/**
📄 CodeRabbit inference engine (AGENTS.md)
Mobile SDK code resides in swift-dash-core-sdk/
Files:
swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swiftswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swiftswift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
dash-spv-ffi/include/dash_spv_ffi.h
📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)
The public C header is generated; ensure it reflects FFI changes after builds
Files:
dash-spv-ffi/include/dash_spv_ffi.h
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📄 CodeRabbit inference engine (swift-dash-core-sdk/CLAUDE.md)
After updating dash-spv-ffi, synchronize the generated header into the Swift SDK using ./sync-headers.sh so Sources/DashSPVFFI/include/dash_spv_ffi.h stays up to date
Files:
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
🧠 Learnings (6)
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/include/dash_spv_ffi.h : The public C header is generated; ensure it reflects FFI changes after builds
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/include/dash_spv_ffi.hdash-spv-ffi/dash_spv_ffi.hswift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:15:29.335Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:29.335Z
Learning: Applies to swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h : After updating dash-spv-ffi, synchronize the generated header into the Swift SDK using ./sync-headers.sh so Sources/DashSPVFFI/include/dash_spv_ffi.h stays up to date
Applied to files:
dash-spv-ffi/include/dash_spv_ffi.hdash-spv-ffi/dash_spv_ffi.hswift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:57.225Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/*.swift : When accessing SPV functionality, use DashSDK public APIs instead of direct client access; add public wrapper methods to DashSDK if needed
Applied to files:
swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:57.225Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/SPVClient.swift : Do not place type definitions in SPVClient.swift; keep types in dedicated files instead
Applied to files:
swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift
📚 Learning: 2025-08-29T04:00:14.154Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-29T04:00:14.154Z
Learning: Applies to {dash-network-ffi,dash-spv-ffi,key-wallet-ffi,swift-dash-core-sdk}/**/*.{rs,c,h,swift} : Be careful with memory management at FFI boundaries (C/Swift interop)
Applied to files:
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
🧬 Code graph analysis (6)
dash-spv-ffi/src/bin/ffi_cli.rs (1)
dash-spv/src/client/mod.rs (1)
peer_count(1299-1301)
dash-spv/src/client/mod.rs (2)
dash-spv/src/client/status_display.rs (1)
sync_progress(74-111)dash-spv/src/types.rs (3)
default(66-82)default(424-426)default(573-602)
dash-spv-ffi/src/types.rs (1)
dash-spv/src/sync/sequential/phases.rs (1)
progress(278-524)
swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swift (4)
dash-spv/src/client/mod.rs (1)
peer_count(1299-1301)dash-spv/tests/block_download_test.rs (1)
peer_count(88-94)dash-spv/tests/edge_case_filter_sync_test.rs (1)
peer_count(88-90)dash-spv/tests/filter_header_verification_test.rs (1)
peer_count(80-82)
dash-spv/src/types.rs (1)
key-wallet-manager/src/wallet_manager/mod.rs (1)
current_height(1035-1037)
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (2)
dash-spv-ffi/src/client.rs (1)
dash_spv_ffi_client_drain_events(371-376)dash-spv-ffi/src/config.rs (1)
dash_spv_ffi_config_set_worker_threads(371-379)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Strict Warnings and Clippy Checks
- GitHub Check: fuzz (dash_deser_net_msg)
- GitHub Check: fuzz (hashes_sha1)
- GitHub Check: RPC Tests (stable, true)
- GitHub Check: fuzz (dash_outpoint_string)
- GitHub Check: fuzz (dash_deserialize_block)
- GitHub Check: fuzz (hashes_sha256)
- GitHub Check: fuzz (dash_deserialize_address)
- GitHub Check: fuzz (dash_deserialize_amount)
- GitHub Check: SPV Components Tests
- GitHub Check: Core Components Tests
🔇 Additional comments (17)
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (3)
86-96: LGTM! The structural change to embed FFISyncProgress is correct.The refactoring to embed
FFISyncProgressasoverviewwithinFFIDetailedSyncProgressimproves the API by providing a cleaner separation between core sync metrics and detailed progress information.
1-994: Ensure header synchronization with dash-spv-ffi.This header file is auto-generated from the dash-spv-ffi crate. Please ensure that after merging these changes, you run
./sync-headers.shto keep the Swift SDK's copy synchronized with the FFI crate's generated header.Based on learnings.
719-719: No duplicate declaration found
The functiondash_spv_ffi_config_set_worker_threadsis declared only once indash_spv_ffi.h(line 719).Likely an incorrect or invalid review comment.
dash-spv-ffi/src/types.rs (1)
106-109: LGTM! Consistent transformation to use nested overview.The implementation correctly populates the
overviewfield usingFFISyncProgress::from(progress.sync_progress.clone()), maintaining consistency with the header file changes.dash-spv-ffi/src/bin/ffi_cli.rs (1)
30-45: LGTM! CLI correctly uses the new nested structure.The display logic has been properly updated to access
header_heightandpeer_countthrough theoverviewfield, maintaining the same user experience while using the refactored structure.dash-spv/src/types.rs (2)
88-89: LGTM! Core type refactoring is well-structured.The addition of
sync_progress: SyncProgressas a nested field provides a clean separation of concerns. The core metrics are now encapsulated inSyncProgress, whileDetailedSyncProgressextends it with performance and timing information.
131-134: LGTM! Consistent usage of nested sync_progress throughout.The percentage and ETA calculations correctly reference
self.sync_progress.header_heightinstead of the removedcurrent_heightfield, maintaining functional consistency.dash-spv-ffi/include/dash_spv_ffi.h (1)
86-96: LGTM! Header changes match the implementation.The FFIDetailedSyncProgress structure correctly embeds FFISyncProgress as
overview, matching the changes in the implementation files.dash-spv/src/client/mod.rs (1)
921-933: LGTM! Clean refactoring to use embedded overview pattern.The change to use
StatusDisplayfor creating the sync progress snapshot and updating it with the latest network state is well-structured. The embedded overview approach centralizes progress information and maintains consistency across the codebase.swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift (4)
11-22: LGTM! Backward compatibility maintained with computed properties.The refactoring to use an
overview: SyncProgressfield while maintainingcurrentHeightandconnectedPeersas computed properties is excellent. This preserves the existing API while adopting the new nested structure.
69-80: LGTM! Clean initializer update.The public initializer correctly accepts the new
overviewparameter while maintaining the rest of the initialization logic unchanged.
92-93: LGTM! FFI integration properly updated.The internal initializer correctly creates the overview from the FFI structure.
310-313: LGTM! Enhanced statistics display.Good addition of filter-related statistics to the dictionary, providing more comprehensive sync progress information.
dash-spv-ffi/dash_spv_ffi.h (1)
86-96: LGTM! Well-structured FFI type refactoring.The
FFIDetailedSyncProgressstruct now properly embedsFFISyncProgressas an overview field. This maintains separation of concerns while providing a comprehensive progress snapshot.Based on learnings
swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swift (3)
14-21: LGTM! Comprehensive sync progress fields added.The new fields provide detailed visibility into the sync state across different components (filter headers, masternodes, filters). This aligns well with the overview pattern adopted throughout the PR.
31-38: LGTM! Sensible default values for optional parameters.Good use of default parameter values maintaining backward compatibility while allowing detailed progress tracking when needed.
65-72: LGTM! FFI mapping properly handles new fields.The internal initializer correctly maps all new FFI fields to the Swift properties.
| return SyncProgressStream(client: self) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove trailing tilde character.
There's a stray ~ character at the end of line 1245 that should be removed.
-}
+}Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift around line
1245, there's a stray trailing tilde character (~) at the end of the line;
remove that character so the line ends cleanly (ensure no extra whitespace or
other stray characters remain and run quick build/lint to confirm no syntax
errors).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not accurate
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove trailing tilde character.
There's a stray ~ character at the end of line 155 that should be removed.
-}
+}Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swift at
line 155, remove the stray trailing tilde character (~) at the end of the line;
edit that line to delete the tilde so the file compiles and contains no
unintended character.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not accurate
There was a problem hiding this 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
🧹 Nitpick comments (9)
dash-spv/src/client/mod.rs (2)
921-933: Avoid overriding header_height after computing SyncProgressYou compute SyncProgress via StatusDisplay and then overwrite header_height with current_height. This risks subtle inconsistencies if StatusDisplay’s calculate_header_height changes. Prefer a single source of truth: either trust the StatusDisplay value or have StatusDisplay accept/compute the absolute height consistently.
- let mut sync_progress = match status_display.sync_progress().await { + let mut sync_progress = match status_display.sync_progress().await { Ok(p) => p, Err(e) => { tracing::warn!("Failed to compute sync progress snapshot: {}", e); SyncProgress::default() } }; // Update peer count with the latest network information. sync_progress.peer_count = self.network.peer_count() as u32; - sync_progress.header_height = current_height; + // If StatusDisplay::sync_progress() returns checkpoint-aware height, keep it. + // Otherwise ensure calculate_header_height uses the same definition as current_height.
965-973: Deduplicate progress snapshot constructionYou build DetailedSyncProgress twice with near-identical logic. Extract a small helper to construct progress from (sync_progress, peer_best, current/abs height) to reduce drift and make maintenance easier.
+ fn build_progress( + sync_progress: SyncProgress, + peer_best: u32, + current_height: u32, + headers_per_second: f64, + total_bytes_downloaded: u64, + sync_start_time: SystemTime, + ) -> DetailedSyncProgress { + DetailedSyncProgress { + sync_progress, + peer_best_height: peer_best, + percentage: if peer_best > 0 { + (current_height as f64 / peer_best as f64 * 100.0).min(100.0) + } else { 0.0 }, + headers_per_second, + bytes_per_second: 0, + estimated_time_remaining: if headers_per_second > 0.0 && peer_best > current_height { + let remaining = peer_best - current_height; + Some(Duration::from_secs_f64(remaining as f64 / headers_per_second)) + } else { None }, + sync_stage: if current_height < peer_best { + crate::types::SyncStage::DownloadingHeaders { start: current_height, end: peer_best } + } else { crate::types::SyncStage::Complete }, + total_headers_processed: current_height as u64, + total_bytes_downloaded, + sync_start_time, + last_update_time: SystemTime::now(), + } + }Then call build_progress in both places.
Also applies to: 974-1026
dash-spv-ffi/src/client.rs (2)
789-821: Progress callback passes ephemeral pointer; document lifetime explicitlyFFIDetailedSyncProgress is boxed per-callback and dropped after the call. Add an explicit safety comment near the callback invocation stating the pointer is only valid during the call to prevent consumers from storing it.
- callback(ffi_progress.as_ref(), *user_data); + // SAFETY: Pointer is valid only for the duration of this call. Do not store. + callback(ffi_progress.as_ref(), *user_data);
1271-1271: Drop misleading log for removed callbackLogging “Filter headers progress callback: false” is confusing now that the field no longer exists. Remove the line or replace with a generic note that per-filter progress callbacks were removed.
- tracing::debug!(" Filter headers progress callback: {}", false); + tracing::debug!(" Per-filter progress callback removed; using detailed progress instead");dash-spv/src/types.rs (1)
782-791: Consider embedding SyncProgress in SpvEvent::SyncProgressFor consistency with the new model, you might evolve this event to carry SyncProgress (plus any extras) rather than raw fields. Optional for now.
dash-spv-ffi/include/dash_spv_ffi.h (1)
86-97: Clarify lifetime/units of transient fields in progress callbacksDocument that stage_message.ptr (and any nested pointers) are only valid for the duration of the progress callback, and specify timestamp/seconds units for sync_start_timestamp and estimated_seconds_remaining in the Rust docs so cbindgen carries it here.
Can you confirm these docs exist in the Rust source that generates this header? As per coding guidelines
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (2)
64-64: worker_threads added: avoid direct struct mutation from SwiftEnsure Swift uses the setter dash_spv_ffi_config_set_worker_threads and not field writes, and add a wrapper in FFIBridge.swift.
If missing, add a thin wrapper:
public func setWorkerThreads(_ threads: UInt32) throws { let rc = dash_spv_ffi_config_set_worker_threads(self.ptr, threads) try FFI.throwIfError(rc) }Based on learnings
278-285: New non-blocking drain_events: expose in Swift APIAdd a Swift wrapper and decide call sites (e.g., timer/runloop, or after enqueueing work) to drive callback delivery.
Example wrapper:
@discardableResult public func drainEvents() throws -> Int32 { let rc = dash_spv_ffi_client_drain_events(self.ptr) try FFI.throwIfError(rc) return rc }Based on learnings
dash-spv-ffi/dash_spv_ffi.h (1)
86-97: Add CI check to ensure dash-spv-ffi headers remain synchronizedHeaders dash-spv-ffi/include/dash_spv_ffi.h and dash-spv-ffi/dash_spv_ffi.h are byte-identical (verified), but automate a diff in CI (or consolidate into one canonical file) to prevent future drift.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
dash-spv-ffi/dash_spv_ffi.h(1 hunks)dash-spv-ffi/include/dash_spv_ffi.h(1 hunks)dash-spv-ffi/src/bin/ffi_cli.rs(2 hunks)dash-spv-ffi/src/callbacks.rs(2 hunks)dash-spv-ffi/src/client.rs(3 hunks)dash-spv-ffi/tests/integration/test_full_workflow.rs(0 hunks)dash-spv-ffi/tests/test_event_callbacks.rs(0 hunks)dash-spv-ffi/tests/unit/test_async_operations.rs(0 hunks)dash-spv/src/client/mod.rs(2 hunks)dash-spv/src/types.rs(2 hunks)swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h(5 hunks)
💤 Files with no reviewable changes (3)
- dash-spv-ffi/tests/test_event_callbacks.rs
- dash-spv-ffi/tests/unit/test_async_operations.rs
- dash-spv-ffi/tests/integration/test_full_workflow.rs
🧰 Additional context used
📓 Path-based instructions (10)
dash-spv-ffi/src/**/*.rs
📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)
dash-spv-ffi/src/**/*.rs: FFI functions must be declared with #[no_mangle] extern "C"
Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)
Provide corresponding _destroy() functions for all FFI-owned types to enforce explicit memory management
Return Rust strings to C as *const c_char; allocate so the caller can free with dash_string_free
Accept input strings from C as *const c_char (borrowed; do not free inputs)
Functions returning pointers transfer ownership to the caller; functions taking pointers only borrow
Add cbindgen annotations for complex types so headers are generated correctly
Files:
dash-spv-ffi/src/callbacks.rsdash-spv-ffi/src/client.rsdash-spv-ffi/src/bin/ffi_cli.rs
dash-spv-ffi/src/callbacks.rs
📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)
Use C function pointers for async progress/completion callbacks; callbacks may be invoked from any thread
Files:
dash-spv-ffi/src/callbacks.rs
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Use proper error types with thiserror and propagate errors appropriately
Use the tokio runtime for async operations in Rust
Use conditional compilation feature flags for optional features (#[cfg(feature = ...)])
Format Rust code with cargo fmt (and enforce via cargo fmt --check)
Run clippy with -D warnings and fix all lints
Adhere to MSRV Rust 1.89 (avoid features requiring newer compiler)
**/*.rs: Format Rust code with rustfmt (per rustfmt.toml); run cargo fmt --all before commits
Lint with clippy; treat warnings as errors in CI
Follow Rust naming: snake_case for functions/variables, UpperCamelCase for types/traits, SCREAMING_SNAKE_CASE for consts
Prefer async using tokio where applicable
Files:
dash-spv-ffi/src/callbacks.rsdash-spv-ffi/src/client.rsdash-spv-ffi/src/bin/ffi_cli.rsdash-spv/src/client/mod.rsdash-spv/src/types.rs
{dash-network-ffi,dash-spv-ffi,key-wallet-ffi,swift-dash-core-sdk}/**/*.{rs,c,h,swift}
📄 CodeRabbit inference engine (CLAUDE.md)
Be careful with memory management at FFI boundaries (C/Swift interop)
Files:
dash-spv-ffi/src/callbacks.rsdash-spv-ffi/src/client.rsdash-spv-ffi/dash_spv_ffi.hdash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/include/dash_spv_ffi.hswift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
**/src/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/src/**/*.rs: Each crate keeps sources in src/
Avoid unwrap()/expect() in library code; use proper error types (e.g., thiserror)
Place unit tests alongside code with #[cfg(test)]
Files:
dash-spv-ffi/src/callbacks.rsdash-spv-ffi/src/client.rsdash-spv-ffi/src/bin/ffi_cli.rsdash-spv/src/client/mod.rsdash-spv/src/types.rs
*-ffi/**
📄 CodeRabbit inference engine (AGENTS.md)
FFI bindings live in *-ffi crates
Files:
dash-spv-ffi/src/callbacks.rsdash-spv-ffi/src/client.rsdash-spv-ffi/dash_spv_ffi.hdash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/include/dash_spv_ffi.h
dash-spv-ffi/include/dash_spv_ffi.h
📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)
The public C header is generated; ensure it reflects FFI changes after builds
Files:
dash-spv-ffi/include/dash_spv_ffi.h
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📄 CodeRabbit inference engine (swift-dash-core-sdk/CLAUDE.md)
After updating dash-spv-ffi, synchronize the generated header into the Swift SDK using ./sync-headers.sh so Sources/DashSPVFFI/include/dash_spv_ffi.h stays up to date
Files:
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
swift-dash-core-sdk/**
📄 CodeRabbit inference engine (AGENTS.md)
Mobile SDK code resides in swift-dash-core-sdk/
Files:
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
dash-spv/**/*.rs
📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)
dash-spv/**/*.rs: Enforce Rust formatting viacargo fmt --checkon all Rust source files
All code must be clippy-clean: runcargo clippy --all-targets --all-features -- -D warnings
Files:
dash-spv/src/client/mod.rsdash-spv/src/types.rs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:29.335Z
Learning: Applies to swift-dash-core-sdk/Sources/**/FFIBridge.swift : Add a Swift wrapper in FFIBridge.swift for each new FFI function, handling type conversions and cross-language error mapping
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/callbacks.rs : Use C function pointers for async progress/completion callbacks; callbacks may be invoked from any thread
Applied to files:
dash-spv-ffi/src/callbacks.rsdash-spv-ffi/src/client.rsdash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/**/*.rs : All code must be clippy-clean: run `cargo clippy --all-targets --all-features -- -D warnings`
Applied to files:
dash-spv-ffi/src/client.rs
📚 Learning: 2025-06-26T16:01:37.609Z
Learnt from: DCG-Claude
PR: dashpay/rust-dashcore#0
File: :0-0
Timestamp: 2025-06-26T16:01:37.609Z
Learning: The mempool tracking infrastructure (UnconfirmedTransaction, MempoolState, configuration, and mempool_filter.rs) is fully implemented and integrated in the Dash SPV client as of this PR, including client logic, FFI APIs, and tests.
Applied to files:
dash-spv-ffi/src/client.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/include/dash_spv_ffi.h : The public C header is generated; ensure it reflects FFI changes after builds
Applied to files:
dash-spv-ffi/dash_spv_ffi.hdash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/include/dash_spv_ffi.hswift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:15:29.335Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:29.335Z
Learning: Applies to swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h : After updating dash-spv-ffi, synchronize the generated header into the Swift SDK using ./sync-headers.sh so Sources/DashSPVFFI/include/dash_spv_ffi.h stays up to date
Applied to files:
dash-spv-ffi/dash_spv_ffi.hdash-spv-ffi/include/dash_spv_ffi.hswift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : FFI functions must be declared with #[no_mangle] extern "C"
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rs
🧬 Code graph analysis (4)
dash-spv-ffi/src/bin/ffi_cli.rs (1)
dash-spv/src/client/mod.rs (1)
peer_count(1337-1339)
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (2)
dash-spv-ffi/src/client.rs (1)
dash_spv_ffi_client_drain_events(361-366)dash-spv-ffi/src/config.rs (1)
dash_spv_ffi_config_set_worker_threads(371-379)
dash-spv/src/client/mod.rs (2)
dash-spv/src/client/status_display.rs (1)
sync_progress(74-111)dash-spv/src/types.rs (3)
default(66-82)default(424-426)default(573-602)
dash-spv/src/types.rs (1)
key-wallet-manager/src/wallet_manager/mod.rs (1)
current_height(1035-1037)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
- GitHub Check: Key Wallet Components Tests
- GitHub Check: fuzz (hashes_sha256)
- GitHub Check: fuzz (hashes_cbor)
- GitHub Check: fuzz (hashes_sha512)
- GitHub Check: fuzz (hashes_json)
- GitHub Check: fuzz (hashes_sha1)
- GitHub Check: SPV Components Tests
- GitHub Check: fuzz (dash_deserialize_block)
- GitHub Check: Strict Warnings and Clippy Checks
- GitHub Check: RPC Tests (stable, true)
- GitHub Check: fuzz (dash_deserialize_amount)
- GitHub Check: fuzz (hashes_sha512_256)
- GitHub Check: Core Components Tests
- GitHub Check: fuzz (dash_deserialize_address)
- GitHub Check: fuzz (dash_outpoint_string)
- GitHub Check: fuzz (dash_deser_net_msg)
🔇 Additional comments (16)
dash-spv-ffi/src/client.rs (4)
252-253: Removal of FilterHeadersProgress event handling is correctEvent forwarding aligns with the updated model; detailed sync progress now covers this data.
938-939: Good: clarify progress routingThe comment makes it clear that detailed progress is the single channel now.
970-1003: All references to removed callbacks/variants cleaned up: grep confirms only comments remain noting removal in callbacks.rs and client.rs; no code, header, or test references to on_filter_headers_progress or FilterHeadersProgress.
145-158: Exposeworker_threadsin FFI headers
No occurrences ofworker_threadsfound in committed.h/.hppfiles; verify cbindgen-generated headers include this field so callers can set it.dash-spv/src/types.rs (3)
88-90: Embedding SyncProgress in DetailedSyncProgress is a solid consolidationThis reduces duplication and keeps the overview consistent across layers.
132-134: Percentage/ETA now use sync_progress.header_heightThis is consistent with the new model. LGTM.
Also applies to: 141-143
25-63: Confirm SystemTime serde support in SyncProgress (dash-spv/src/types.rs): verify yourserdesetup supports serializing/deserializing thesync_startandlast_updateSystemTime fields or switch to explicit epoch‐based types.dash-spv-ffi/src/bin/ffi_cli.rs (2)
170-181: Minimal event callbacks setup aligns with removed per-filter callbackNo dangling fields; clean initialization.
34-38: FFIDetailedSyncProgress ‘overview’ field confirmed FFI struct definesoverview(nosync_progress), matching the CLI’sp.overview.*usage.dash-spv-ffi/src/callbacks.rs (3)
148-150: Clean removal of on_filter_headers_progress from FFIEventCallbacksMatches the new progress model; fewer moving parts at the FFI boundary.
166-180: Default impl updated accordinglyNo references left; good.
388-389: Comment clarifies public API changeClear guidance for integrators. LGTM.
dash-spv-ffi/include/dash_spv_ffi.h (1)
86-97: FFIDetailedSyncProgress redesign looks correctNested overview consolidates duplicated fields; types/ordering are FFI-safe.
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (3)
397-398: Doc tweak LGTMClarifies cancel semantics; no API change.
707-714: Setter for worker_threads present: confirm default semantics in docs0 = auto is implied in the comment; ensure Swift docs mirror this and wrappers don’t clamp 0.
Based on learnings
86-97: FFIDetailedSyncProgress headers are in sync. FFISyncProgress presence and fields match upstream; verify Swift models map viaoverviewand leverage computed properties (e.g.,currentHeight,peerCount).
Co-authored-by: PastaPastaPasta <[email protected]>
Co-authored-by: PastaPastaPasta <[email protected]>
Co-authored-by: PastaPastaPasta <[email protected]>
Co-authored-by: PastaPastaPasta <[email protected]>
…nto fix/syncProgress
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
dash-spv/src/sync/filters.rs (1)
2882-2894: Avoid double-countingfilters_receivedupdatesLine 2883 calls
Self::update_filter_receivedbefore we know whetherheightwas already present. On retries or duplicate deliveries we’ll hit this branch again, incrementingfilters_receivedwithout adding a new height, so the reported progress can exceed the total requested filters. Please insert the height first, check if it was new, and only then bump the counter.- if let Ok(Some(height)) = storage.get_header_height_by_hash(block_hash).await.map_err(|e| { - SyncError::Storage(format!("Failed to get header height by hash: {}", e)) - })? { - // Increment the received counter so high-level progress reflects the update - Self::update_filter_received(stats).await; - - // Get the shared filter heights arc from stats - let stats_lock = stats.read().await; - let received_filter_heights = stats_lock.received_filter_heights.clone(); - drop(stats_lock); // Release the stats lock before acquiring the mutex - - // Now lock the heights and insert - let mut heights = received_filter_heights.lock().await; - heights.insert(height); + if let Ok(Some(height)) = storage.get_header_height_by_hash(block_hash).await.map_err(|e| { + SyncError::Storage(format!("Failed to get header height by hash: {}", e)) + })? { + // Get the shared filter heights arc from stats + let stats_lock = stats.read().await; + let received_filter_heights = stats_lock.received_filter_heights.clone(); + drop(stats_lock); // Release the stats lock before acquiring the mutex + + // Now lock the heights and insert + let mut heights = received_filter_heights.lock().await; + let is_new = heights.insert(height); + drop(heights); + + if is_new { + // Increment the received counter so high-level progress reflects the update + Self::update_filter_received(stats).await; + }dash-spv-ffi/src/client.rs (1)
808-824: Release callback locks before invoking user FFI callbackLines 808-824 invoke the progress callback while holding both
sync_callbacksandCALLBACK_REGISTRYmutex guards. If the callback re-enters the FFI (e.g., callingdash_spv_ffi_client_cancel_synconce enough data is downloaded), it tries to take those same locks insidestop_client_internal, leading to a guaranteed deadlock. Pull the callback pointer and user data out of the locks first, drop the guards, and only then call back into user code.@@ - { - let cb_guard = sync_callbacks_clone.lock().unwrap(); - - if let Some(ref callback_data) = *cb_guard { - let registry = CALLBACK_REGISTRY.lock().unwrap(); - if let Some(CallbackInfo::Detailed { - progress_callback: Some(callback), - user_data, - .. - }) = registry.get(callback_data.callback_id) - { - // SAFETY: The callback and user_data are safely stored in the registry - // and accessed through thread-safe mechanisms. The registry ensures - // proper lifetime management without raw pointer passing across threads. - callback(ffi_progress.as_ref(), *user_data); - } - } - } + let callback_id = { + let cb_guard = sync_callbacks_clone.lock().unwrap(); + cb_guard.as_ref().map(|data| data.callback_id) + }; + + let (progress_callback, user_data_ptr) = if let Some(callback_id) = + callback_id + { + let registry = CALLBACK_REGISTRY.lock().unwrap(); + if let Some(CallbackInfo::Detailed { + progress_callback: Some(callback), + user_data, + .. + }) = registry.get(callback_id) + { + (Some(*callback), *user_data) + } else { + (None, std::ptr::null_mut()) + } + } else { + (None, std::ptr::null_mut()) + }; + + if let Some(callback) = progress_callback { + // SAFETY: The callback and user_data are retrieved under the registry lock, + // and we only pass borrowed data whose lifetime is bound to this call. + callback(ffi_progress.as_ref(), user_data_ptr); + }swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swift (1)
98-117: Update needed for new FFISyncStage enum values.The
ffiStatusmapping inSyncStatus.init?(ffiStatus:)needs to be updated to handle the newDownloadingFilterHeaders(5) andDownloadingFilters(6) enum values, and adjust the mapping forComplete(now 7) andFailed(now 8).Apply this diff to fix the enum mapping:
internal init?(ffiStatus: UInt32) { switch ffiStatus { case 0: self = .idle case 1: self = .connecting case 2: self = .downloadingHeaders - case 3: - self = .downloadingFilters - case 4: - self = .scanning - case 5: - self = .synced - case 6: - self = .error + case 3: + self = .scanning // Maps to Validating + case 4: + self = .scanning // Maps to Storing + case 5: + self = .downloadingFilters // Maps to DownloadingFilterHeaders + case 6: + self = .downloadingFilters // Maps to DownloadingFilters + case 7: + self = .synced // Maps to Complete + case 8: + self = .error // Maps to Failed default: return nil } }
🧹 Nitpick comments (1)
dash-spv-ffi/src/types.rs (1)
46-58: Handle the unwrap_or(0) pattern more explicitly for Optional values.The conversion from
Option<u32>tou32usingunwrap_or(0)forlast_synced_filter_heightmight hide meaningful state. Consider documenting that 0 indicates "not yet synced" vs actual height 0.Also, the cast from
usizetou32on line 54 could potentially overflow on 32-bit systems iffilters_downloadedexceedsu32::MAX. Consider using saturating conversion:- filters_downloaded: progress.filters_downloaded as u32, + filters_downloaded: progress.filters_downloaded.min(u32::MAX as usize) as u32,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
dash-spv-ffi/dash_spv_ffi.h(2 hunks)dash-spv-ffi/include/dash_spv_ffi.h(2 hunks)dash-spv-ffi/src/bin/ffi_cli.rs(3 hunks)dash-spv-ffi/src/client.rs(2 hunks)dash-spv-ffi/src/types.rs(5 hunks)dash-spv-ffi/tests/performance/test_benchmarks.rs(2 hunks)dash-spv-ffi/tests/test_types.rs(1 hunks)dash-spv-ffi/tests/unit/test_type_conversions.rs(0 hunks)dash-spv/src/client/mod.rs(6 hunks)dash-spv/src/client/status_display.rs(0 hunks)dash-spv/src/storage/sync_state.rs(1 hunks)dash-spv/src/sync/filters.rs(1 hunks)dash-spv/src/sync/sequential/mod.rs(1 hunks)dash-spv/src/types.rs(3 hunks)swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h(6 hunks)swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift(8 hunks)swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swift(4 hunks)
💤 Files with no reviewable changes (2)
- dash-spv-ffi/tests/unit/test_type_conversions.rs
- dash-spv/src/client/status_display.rs
🧰 Additional context used
📓 Path-based instructions (13)
dash-spv-ffi/src/**/*.rs
📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)
dash-spv-ffi/src/**/*.rs: FFI functions must be declared with #[no_mangle] extern "C"
Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)
Provide corresponding _destroy() functions for all FFI-owned types to enforce explicit memory management
Return Rust strings to C as *const c_char; allocate so the caller can free with dash_string_free
Accept input strings from C as *const c_char (borrowed; do not free inputs)
Functions returning pointers transfer ownership to the caller; functions taking pointers only borrow
Add cbindgen annotations for complex types so headers are generated correctly
Files:
dash-spv-ffi/src/client.rsdash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/src/types.rs
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Use proper error types with thiserror and propagate errors appropriately
Use the tokio runtime for async operations in Rust
Use conditional compilation feature flags for optional features (#[cfg(feature = ...)])
Format Rust code with cargo fmt (and enforce via cargo fmt --check)
Run clippy with -D warnings and fix all lints
Adhere to MSRV Rust 1.89 (avoid features requiring newer compiler)
**/*.rs: Format Rust code with rustfmt (per rustfmt.toml); run cargo fmt --all before commits
Lint with clippy; treat warnings as errors in CI
Follow Rust naming: snake_case for functions/variables, UpperCamelCase for types/traits, SCREAMING_SNAKE_CASE for consts
Prefer async using tokio where applicable
Files:
dash-spv-ffi/src/client.rsdash-spv/src/storage/sync_state.rsdash-spv/src/types.rsdash-spv/src/sync/filters.rsdash-spv-ffi/tests/performance/test_benchmarks.rsdash-spv-ffi/tests/test_types.rsdash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/src/types.rsdash-spv/src/client/mod.rsdash-spv/src/sync/sequential/mod.rs
{dash-network-ffi,dash-spv-ffi,key-wallet-ffi,swift-dash-core-sdk}/**/*.{rs,c,h,swift}
📄 CodeRabbit inference engine (CLAUDE.md)
Be careful with memory management at FFI boundaries (C/Swift interop)
Files:
dash-spv-ffi/src/client.rsdash-spv-ffi/tests/performance/test_benchmarks.rsdash-spv-ffi/tests/test_types.rsdash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/include/dash_spv_ffi.hswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swiftdash-spv-ffi/dash_spv_ffi.hdash-spv-ffi/src/types.rsswift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.hswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift
**/src/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/src/**/*.rs: Each crate keeps sources in src/
Avoid unwrap()/expect() in library code; use proper error types (e.g., thiserror)
Place unit tests alongside code with #[cfg(test)]
Files:
dash-spv-ffi/src/client.rsdash-spv/src/storage/sync_state.rsdash-spv/src/types.rsdash-spv/src/sync/filters.rsdash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/src/types.rsdash-spv/src/client/mod.rsdash-spv/src/sync/sequential/mod.rs
*-ffi/**
📄 CodeRabbit inference engine (AGENTS.md)
FFI bindings live in *-ffi crates
Files:
dash-spv-ffi/src/client.rsdash-spv-ffi/tests/performance/test_benchmarks.rsdash-spv-ffi/tests/test_types.rsdash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/include/dash_spv_ffi.hdash-spv-ffi/dash_spv_ffi.hdash-spv-ffi/src/types.rs
dash-spv/**/*.rs
📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)
dash-spv/**/*.rs: Enforce Rust formatting viacargo fmt --checkon all Rust source files
All code must be clippy-clean: runcargo clippy --all-targets --all-features -- -D warnings
Files:
dash-spv/src/storage/sync_state.rsdash-spv/src/types.rsdash-spv/src/sync/filters.rsdash-spv/src/client/mod.rsdash-spv/src/sync/sequential/mod.rs
dash-spv/src/storage/**/*.rs
📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)
Provide both
MemoryStorageManagerandDiskStorageManagerbehind theStorageManagertrait
Files:
dash-spv/src/storage/sync_state.rs
**/tests/**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
Use proptest for property-based testing where appropriate
**/tests/**/*.rs: Integration tests must live under tests/ (e.g., rpc-integration-test)
Use descriptive test names (e.g., test_parse_address_mainnet) for integration tests
Mark network-dependent or long-running tests with #[ignore] and run with -- --ignored
Add regression tests for fixes; consider property tests (e.g., proptest) where valuable
Keep test vectors deterministic
Files:
dash-spv-ffi/tests/performance/test_benchmarks.rsdash-spv-ffi/tests/test_types.rs
dash-spv-ffi/include/dash_spv_ffi.h
📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)
The public C header is generated; ensure it reflects FFI changes after builds
Files:
dash-spv-ffi/include/dash_spv_ffi.h
swift-dash-core-sdk/Sources/**/*.swift
📄 CodeRabbit inference engine (swift-dash-core-sdk/CLAUDE.md)
swift-dash-core-sdk/Sources/**/*.swift: Use actors for state management to maintain thread safety in SDK components
Use @available checks for features that require newer OS versions (e.g., SwiftData on iOS 17+)
Files:
swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swiftswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift
{key-wallet,swift-dash-core-sdk}/**/*.{rs,swift}
📄 CodeRabbit inference engine (CLAUDE.md)
Never log or expose private keys
Files:
swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swiftswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift
swift-dash-core-sdk/**
📄 CodeRabbit inference engine (AGENTS.md)
Mobile SDK code resides in swift-dash-core-sdk/
Files:
swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swiftswift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.hswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📄 CodeRabbit inference engine (swift-dash-core-sdk/CLAUDE.md)
After updating dash-spv-ffi, synchronize the generated header into the Swift SDK using ./sync-headers.sh so Sources/DashSPVFFI/include/dash_spv_ffi.h stays up to date
Files:
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
🧠 Learnings (11)
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/callbacks.rs : Use C function pointers for async progress/completion callbacks; callbacks may be invoked from any thread
Applied to files:
dash-spv-ffi/src/client.rsdash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-06-26T16:01:37.609Z
Learnt from: DCG-Claude
PR: dashpay/rust-dashcore#0
File: :0-0
Timestamp: 2025-06-26T16:01:37.609Z
Learning: The mempool tracking infrastructure (UnconfirmedTransaction, MempoolState, configuration, and mempool_filter.rs) is fully implemented and integrated in the Dash SPV client as of this PR, including client logic, FFI APIs, and tests.
Applied to files:
dash-spv-ffi/src/client.rs
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/**/*.rs : All code must be clippy-clean: run `cargo clippy --all-targets --all-features -- -D warnings`
Applied to files:
dash-spv-ffi/src/client.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/include/dash_spv_ffi.h : The public C header is generated; ensure it reflects FFI changes after builds
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/include/dash_spv_ffi.hdash-spv-ffi/dash_spv_ffi.hswift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : FFI functions must be declared with #[no_mangle] extern "C"
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rsdash-spv-ffi/src/types.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Provide corresponding _destroy() functions for all FFI-owned types to enforce explicit memory management
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-08-16T04:15:29.335Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:29.335Z
Learning: Applies to swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h : After updating dash-spv-ffi, synchronize the generated header into the Swift SDK using ./sync-headers.sh so Sources/DashSPVFFI/include/dash_spv_ffi.h stays up to date
Applied to files:
dash-spv-ffi/include/dash_spv_ffi.hdash-spv-ffi/dash_spv_ffi.hswift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Coordinate synchronization phases with `SequentialSyncManager`; each phase must complete before the next begins
Applied to files:
dash-spv/src/client/mod.rs
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:57.225Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/SPVClient.swift : Do not place type definitions in SPVClient.swift; keep types in dedicated files instead
Applied to files:
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.hswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift
📚 Learning: 2025-08-16T04:15:57.225Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: swift-dash-core-sdk/Examples/DashHDWalletExample/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:15:57.225Z
Learning: Applies to swift-dash-core-sdk/Examples/DashHDWalletExample/**/*.swift : When accessing SPV functionality, use DashSDK public APIs instead of direct client access; add public wrapper methods to DashSDK if needed
Applied to files:
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.hswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift
🧬 Code graph analysis (6)
dash-spv/src/types.rs (1)
key-wallet-manager/src/wallet_manager/mod.rs (1)
current_height(1035-1037)
dash-spv-ffi/src/bin/ffi_cli.rs (1)
dash-spv/src/client/mod.rs (1)
peer_count(1396-1398)
swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swift (2)
dash-spv/src/sync/sequential/phases.rs (1)
progress(278-524)dash-spv/src/client/mod.rs (1)
peer_count(1396-1398)
dash-spv-ffi/src/types.rs (1)
dash-spv/src/sync/sequential/phases.rs (1)
progress(278-524)
dash-spv/src/client/mod.rs (4)
dash-spv/src/client/status_display.rs (1)
sync_progress(74-108)dash-spv/src/network/mod.rs (2)
peer_count(56-56)peer_count(254-260)dash-spv/src/types.rs (3)
default(57-70)default(420-422)default(569-598)dash-spv/src/sync/sequential/phases.rs (1)
progress(278-524)
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (2)
dash-spv-ffi/src/client.rs (1)
dash_spv_ffi_client_drain_events(360-365)dash-spv-ffi/src/config.rs (1)
dash_spv_ffi_config_set_worker_threads(371-379)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
- GitHub Check: fuzz (hashes_sha512)
- GitHub Check: fuzz (hashes_json)
- GitHub Check: Core Components Tests
- GitHub Check: fuzz (hashes_sha1)
- GitHub Check: fuzz (hashes_cbor)
- GitHub Check: fuzz (hashes_ripemd160)
- GitHub Check: fuzz (hashes_sha512_256)
- GitHub Check: fuzz (dash_deserialize_script)
- GitHub Check: fuzz (dash_script_bytes_to_asm_fmt)
- GitHub Check: fuzz (dash_deserialize_witness)
- GitHub Check: fuzz (dash_deserialize_block)
- GitHub Check: fuzz (hashes_sha256)
- GitHub Check: fuzz (dash_deserialize_amount)
- GitHub Check: fuzz (dash_deserialize_address)
- GitHub Check: RPC Tests (stable, true)
- GitHub Check: fuzz (dash_deser_net_msg)
- GitHub Check: fuzz (dash_outpoint_string)
- GitHub Check: Strict Warnings and Clippy Checks
🔇 Additional comments (35)
dash-spv/src/types.rs (3)
76-78: LGTM! Embedded sync progress overview structure.The updated
DetailedSyncProgressstructure now properly embedsSyncProgressassync_progress, replacing the previous individual fields. This aligns with the broader changes that centralize progress information into a single overview structure.
111-118: Well-designed filter sync stage additions.The new
DownloadingFilterHeadersandDownloadingFiltersvariants provide proper structure for tracking different aspects of filter synchronization with meaningful progress fields (current/target for headers, completed/total for filters).
128-129: Verify calculation consistency across stages.The calculation methods now correctly use
self.sync_progress.header_heightinstead of a direct field, maintaining consistency with the new embedded structure. Ensure all sync stage calculations use the embedded progress data consistently.Also applies to: 137-138
dash-spv-ffi/src/bin/ffi_cli.rs (3)
34-37: Correctly updated to use embedded overview structure.The progress callback now accesses
p.overview.header_heightandp.overview.peer_countfrom the embeddedFFISyncProgressoverview, maintaining consistency with the restructuredFFIDetailedSyncProgress.
170-182: Properly cleaned up event callbacks.The removal of
on_filter_headers_progressfrom theFFIEventCallbacksinitialization aligns with the broader changes that eliminate per-header progress callbacks in favor of the overview-based progress reporting.
209-213: Improved completion logic with embedded progress.The completion detection now uses
prog.header_height >= prog.filter_header_heightalong with other conditions, properly utilizing the embedded overview structure for determining sync completion status.dash-spv/src/client/mod.rs (4)
22-26: Proper import and export of sync phase components.The addition of
SyncPhaseimport andSyncStageexport provides the necessary type mapping infrastructure for the phase-to-stage conversion functionality.
152-205: Well-designed phase-to-stage mapping function.The
map_phase_to_stagefunction provides comprehensive mapping from internal sync phases to public sync stages, handling all sync phases appropriately and providing meaningful progress context for each stage.
961-980: Enhanced progress reporting with embedded overview.The progress reporting now properly constructs
SyncProgresssnapshots and embeds them inDetailedSyncProgress, providing comprehensive progress information including peer count, header height, and filter sync status. The emission logic correctly tracks changes to avoid duplicate progress events.Also applies to: 1015-1087
2032-2036: Clear logging message for resume state.The logging message correctly references
header_heightandfilter_header_heightfrom the saved state, providing clear visibility into the resume operation.dash-spv-ffi/include/dash_spv_ffi.h (4)
75-83: New FFISyncProgress structure properly defined.The FFISyncProgress struct provides comprehensive sync progress information including header heights, masternode height, peer count, and filter sync status. This replaces individual boolean flags with a more informative overview structure.
92-92: Correctly updated to embed overview structure.The FFIDetailedSyncProgress now contains an
overviewfield of typeFFISyncProgressinstead of separatecurrent_heightandconnected_peersfields, providing a cleaner and more comprehensive progress representation.
151-161: Properly removed filter headers progress callback.The removal of the
on_filter_headers_progressfield fromFFIEventCallbacksaligns with the elimination of per-header progress callbacks in favor of the overview-based progress reporting system.
31-34: No action needed: Swift SDK mapping covers new FFISyncStage values. SPVClient.swift’sinit(ffiStage:)already handles raw values 5–8, mapping them to.downloadingFilterHeaders,.downloadingFilters,.complete, and.failed.swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swift (2)
14-18: New fields properly added to sync progress model.The addition of
filterHeaderHeight,masternodeHeight,peerCount,filtersDownloaded, andlastSyncedFilterHeightprovides comprehensive sync status information matching the FFISyncProgress structure.
59-63: Correctly mapped FFI progress to new properties.The internal FFI-based initializer properly maps all fields from
FFISyncProgressto the corresponding Swift properties, providing accurate progress information from the underlying Rust implementation.dash-spv-ffi/src/types.rs (6)
37-44: LGTM! Clean FFISyncProgress struct implementation.The new
FFISyncProgressstruct correctly encapsulates all sync-related progress fields with appropriate types. The structure aligns well with the FFI boundaries and follows Rust naming conventions.
68-72: LGTM! Updated FFISyncStage enum values are correct.The addition of
DownloadingFilterHeaders = 5andDownloadingFilters = 6with subsequent renumbering ofComplete = 7andFailed = 8is properly implemented.
88-93: LGTM! Proper handling of new SyncStage variants.The FFI conversion correctly maps the new
DownloadingFilterHeadersandDownloadingFiltersvariants from the Rust enum to the FFI enum.
108-108: LGTM! Clean integration of overview field.The
overview: FFISyncProgressfield properly replaces the individual sync progress fields, providing a cleaner and more maintainable structure.
130-137: LGTM! Informative stage messages for new sync stages.The stage messages correctly describe the filter header and filter downloading progress with appropriate current/target information.
142-154: LGTM! Proper construction of FFIDetailedSyncProgress with embedded overview.The conversion properly creates the overview from the sync progress and correctly integrates it into the FFIDetailedSyncProgress struct.
swift-dash-core-sdk/Sources/DashSPVFFI/include/dash_spv_ffi.h (6)
31-33: LGTM! FFISyncStage enum values properly updated.The addition of
DownloadingFilterHeaders = 5andDownloadingFilters = 6with renumberedComplete = 7andFailed = 8correctly aligns with the Rust FFI definitions.Based on learnings.
75-83: LGTM! Well-structured FFISyncProgress type.The new FFISyncProgress struct properly defines all sync progress fields with appropriate C types and follows FFI naming conventions.
92-92: LGTM! Clean integration of overview field in FFIDetailedSyncProgress.Replacing individual sync fields with the embedded
struct FFISyncProgress overviewprovides better encapsulation and maintainability.
277-283: LGTM! Proper documentation for new drain_events function.The function declaration and safety documentation are well-written and follow FFI conventions.
396-397: Updated cancellation documentation accurately reflects new behavior.The documentation correctly states that cancellation now "stops the SPV client, clears callbacks, and joins active threads so the sync operation halts immediately."
706-712: Remove duplicate declaration of dash_spv_ffi_config_set_worker_threads.This function is declared twice - once here at lines 706-712 and again in the actual implementation section. The duplicate declaration should be removed to avoid confusion.
Based on learnings.
⛔ Skipped due to learnings
Learnt from: CR PR: dashpay/rust-dashcore#0 File: dash-spv-ffi/CLAUDE.md:0-0 Timestamp: 2025-08-16T04:14:07.718Z Learning: Applies to dash-spv-ffi/include/dash_spv_ffi.h : The public C header is generated; ensure it reflects FFI changes after buildsswift-dash-core-sdk/Sources/SwiftDashCoreSDK/Core/SPVClient.swift (7)
11-23: LGTM! Clean refactor to use overview field.The restructuring to embed
overview: SyncProgressand exposecurrentHeightandconnectedPeersas computed properties is a clean architectural improvement that maintains backwards compatibility.
110-116: LGTM! Properly updated SyncStage enum.The addition of
downloadingFilterHeadersanddownloadingFilterscases correctly aligns with the FFI layer changes.
130-133: LGTM! Correct FFI enum mapping.The switch cases for values 5 and 6 correctly map to the new filter-related sync stages.
151-154: LGTM! Clear descriptions for new sync stages.The descriptions "Downloading filter headers" and "Downloading filters" clearly communicate the sync stage purpose to users.
183-186: LGTM! Appropriate icons for new sync stages.The icons 🧾 for filter headers and 🪄 for filters provide good visual differentiation.
324-326: LGTM! Enhanced statistics with new sync progress fields.The addition of Filter Header Height, Filters Downloaded, and Peer Count to the statistics dictionary properly exposes the new overview fields for debugging and monitoring.
1259-1259: No trailing tilde character found at line 1259.The line ends cleanly with a closing brace
}. The previously reported issue appears to have been resolved.
| headersSynced: Bool = false, | ||
| filterHeadersSynced: Bool = false, | ||
| masternodesSynced: Bool = false, | ||
| filtersDownloaded: UInt32 = 0, | ||
| lastSyncedFilterHeight: UInt32 = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent parameter names in public initializer.
The public initializer includes deprecated boolean parameters (headersSynced, filterHeadersSynced, masternodesSynced) that are not used in the property assignments, while missing some of the new fields from the parameter list. This creates confusion and potential API inconsistency.
Apply this diff to fix the parameter consistency:
public init(
currentHeight: UInt32,
totalHeight: UInt32,
progress: Double,
status: SyncStatus,
estimatedTimeRemaining: TimeInterval? = nil,
message: String? = nil,
filterSyncAvailable: Bool = false,
filterHeaderHeight: UInt32 = 0,
masternodeHeight: UInt32 = 0,
peerCount: UInt32 = 0,
- headersSynced: Bool = false,
- filterHeadersSynced: Bool = false,
- masternodesSynced: Bool = false,
filtersDownloaded: UInt32 = 0,
lastSyncedFilterHeight: UInt32 = 0
) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| headersSynced: Bool = false, | |
| filterHeadersSynced: Bool = false, | |
| masternodesSynced: Bool = false, | |
| filtersDownloaded: UInt32 = 0, | |
| lastSyncedFilterHeight: UInt32 = 0 | |
| public init( | |
| currentHeight: UInt32, | |
| totalHeight: UInt32, | |
| progress: Double, | |
| status: SyncStatus, | |
| estimatedTimeRemaining: TimeInterval? = nil, | |
| message: String? = nil, | |
| filterSyncAvailable: Bool = false, | |
| filterHeaderHeight: UInt32 = 0, | |
| masternodeHeight: UInt32 = 0, | |
| peerCount: UInt32 = 0, | |
| filtersDownloaded: UInt32 = 0, | |
| lastSyncedFilterHeight: UInt32 = 0 | |
| ) { | |
| // existing initializer body… | |
| } |
🤖 Prompt for AI Agents
In swift-dash-core-sdk/Sources/SwiftDashCoreSDK/Models/SyncProgress.swift around
lines 31-35, the public initializer parameters are inconsistent with the
struct's properties: deprecated booleans (headersSynced, filterHeadersSynced,
masternodesSynced) are present but not assigned, and the newer fields
(filtersDownloaded, lastSyncedFilterHeight) are missing from the parameter list;
update the initializer signature to accept parameters that match the actual
properties (include filtersDownloaded: UInt32 = 0 and lastSyncedFilterHeight:
UInt32 = 0, remove the unused deprecated boolean parameters or mark them
deprecated if maintaining source-compatibility), and inside the initializer
assign each incoming parameter to the corresponding property so names/types and
default values align with the struct fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
dash-spv-ffi/src/bin/ffi_cli.rs(3 hunks)dash-spv/src/client/mod.rs(7 hunks)dash-spv/src/client/status_display.rs(0 hunks)dash-spv/src/sync/filters.rs(1 hunks)dash-spv/src/sync/sequential/mod.rs(1 hunks)
💤 Files with no reviewable changes (1)
- dash-spv/src/client/status_display.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- dash-spv/src/sync/filters.rs
🧰 Additional context used
📓 Path-based instructions (6)
dash-spv-ffi/src/**/*.rs
📄 CodeRabbit inference engine (dash-spv-ffi/CLAUDE.md)
dash-spv-ffi/src/**/*.rs: FFI functions must be declared with #[no_mangle] extern "C"
Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)
Provide corresponding _destroy() functions for all FFI-owned types to enforce explicit memory management
Return Rust strings to C as *const c_char; allocate so the caller can free with dash_string_free
Accept input strings from C as *const c_char (borrowed; do not free inputs)
Functions returning pointers transfer ownership to the caller; functions taking pointers only borrow
Add cbindgen annotations for complex types so headers are generated correctly
Files:
dash-spv-ffi/src/bin/ffi_cli.rs
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Use proper error types with thiserror and propagate errors appropriately
Use the tokio runtime for async operations in Rust
Use conditional compilation feature flags for optional features (#[cfg(feature = ...)])
Format Rust code with cargo fmt (and enforce via cargo fmt --check)
Run clippy with -D warnings and fix all lints
Adhere to MSRV Rust 1.89 (avoid features requiring newer compiler)
**/*.rs: Format Rust code with rustfmt (per rustfmt.toml); run cargo fmt --all before commits
Lint with clippy; treat warnings as errors in CI
Follow Rust naming: snake_case for functions/variables, UpperCamelCase for types/traits, SCREAMING_SNAKE_CASE for consts
Prefer async using tokio where applicable
Files:
dash-spv-ffi/src/bin/ffi_cli.rsdash-spv/src/client/mod.rsdash-spv/src/sync/sequential/mod.rs
{dash-network-ffi,dash-spv-ffi,key-wallet-ffi,swift-dash-core-sdk}/**/*.{rs,c,h,swift}
📄 CodeRabbit inference engine (CLAUDE.md)
Be careful with memory management at FFI boundaries (C/Swift interop)
Files:
dash-spv-ffi/src/bin/ffi_cli.rs
**/src/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/src/**/*.rs: Each crate keeps sources in src/
Avoid unwrap()/expect() in library code; use proper error types (e.g., thiserror)
Place unit tests alongside code with #[cfg(test)]
Files:
dash-spv-ffi/src/bin/ffi_cli.rsdash-spv/src/client/mod.rsdash-spv/src/sync/sequential/mod.rs
*-ffi/**
📄 CodeRabbit inference engine (AGENTS.md)
FFI bindings live in *-ffi crates
Files:
dash-spv-ffi/src/bin/ffi_cli.rs
dash-spv/**/*.rs
📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)
dash-spv/**/*.rs: Enforce Rust formatting viacargo fmt --checkon all Rust source files
All code must be clippy-clean: runcargo clippy --all-targets --all-features -- -D warnings
Files:
dash-spv/src/client/mod.rsdash-spv/src/sync/sequential/mod.rs
🧠 Learnings (8)
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/callbacks.rs : Use C function pointers for async progress/completion callbacks; callbacks may be invoked from any thread
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/include/dash_spv_ffi.h : The public C header is generated; ensure it reflects FFI changes after builds
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : FFI functions must be declared with #[no_mangle] extern "C"
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Expose complex Rust types to C as opaque pointers (e.g., FFIDashSpvClient*)
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Provide corresponding _destroy() functions for all FFI-owned types to enforce explicit memory management
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-08-16T04:14:07.718Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-08-16T04:14:07.718Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Add cbindgen annotations for complex types so headers are generated correctly
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/**/*.rs : All code must be clippy-clean: run `cargo clippy --all-targets --all-features -- -D warnings`
Applied to files:
dash-spv-ffi/src/bin/ffi_cli.rs
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Coordinate synchronization phases with `SequentialSyncManager`; each phase must complete before the next begins
Applied to files:
dash-spv/src/client/mod.rs
🧬 Code graph analysis (2)
dash-spv-ffi/src/bin/ffi_cli.rs (1)
dash-spv/src/client/mod.rs (1)
peer_count(1389-1391)
dash-spv/src/client/mod.rs (6)
dash-spv/src/client/status_display.rs (1)
sync_progress(74-108)dash-spv/src/network/multi_peer.rs (1)
peer_count(1092-1095)dash-spv/src/network/mod.rs (2)
peer_count(56-56)peer_count(254-260)dash-spv/src/network/mock.rs (1)
peer_count(155-161)dash-spv/src/types.rs (3)
default(57-70)default(420-422)default(569-598)dash-spv/src/sync/sequential/phases.rs (1)
progress(278-524)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
- GitHub Check: RPC Tests (stable, true)
- GitHub Check: Strict Warnings and Clippy Checks
- GitHub Check: fuzz (hashes_sha512)
- GitHub Check: fuzz (dash_deserialize_script)
- GitHub Check: fuzz (hashes_sha256)
- GitHub Check: fuzz (hashes_cbor)
- GitHub Check: fuzz (dash_deser_net_msg)
- GitHub Check: fuzz (dash_outpoint_string)
- GitHub Check: fuzz (hashes_sha512_256)
- GitHub Check: fuzz (dash_deserialize_block)
- GitHub Check: fuzz (hashes_ripemd160)
- GitHub Check: fuzz (hashes_json)
- GitHub Check: fuzz (dash_script_bytes_to_asm_fmt)
- GitHub Check: fuzz (dash_deserialize_amount)
- GitHub Check: fuzz (dash_deserialize_address)
Summary by CodeRabbit
New Features
Improvements
Refactor
Breaking Change