-
Notifications
You must be signed in to change notification settings - Fork 9
refactor: move Send + Sync + 'static bounds into trait definitions
#331
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
Conversation
These bounds are required almost everywhere anyway, so making them explicit in the trait definitions reduces lots of repetitions. - Add `'static` to `StorageManager`, `NetworkManager`, and `WalletInterface` traits - Remove redundant bounds where traits are used
📝 WalkthroughWalkthroughThe pull request systematically removes Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
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: 0
🧹 Nitpick comments (1)
dash-spv/src/storage/mod.rs (1)
73-73: LGTM: Centralized'staticbound improves consistency.Adding
'staticto the trait definition is the right approach - it removes repetition across call sites while making the trait's lifetime requirements explicit. This aligns with the usage pattern ofArc<dyn StorageManager>mentioned in the learnings.Optional: Enhance documentation to explain `'static` requirement
Consider adding a brief note to the documentation about the
'staticbound:/// ## Implementation Requirements /// /// Implementations must ensure that: +/// - The implementation is `'static` (no borrowed data with shorter lifetimes) /// - All operations are atomic at the logical level (e.g., all headers in a batch succeed or fail together) /// - Read operations are consistent (no partial reads of in-progress writes) /// - The implementation is safe to move between threads (`Send`) /// - The implementation can be referenced from multiple threads (`Sync`)This would clarify why
'staticis required (for Arc-based sharing in async contexts).
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (29)
dash-spv/src/client/block_processor.rsdash-spv/src/client/chainlock.rsdash-spv/src/client/core.rsdash-spv/src/client/events.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/mempool.rsdash-spv/src/client/message_handler.rsdash-spv/src/client/progress.rsdash-spv/src/client/queries.rsdash-spv/src/client/status_display.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/transactions.rsdash-spv/src/main.rsdash-spv/src/network/mod.rsdash-spv/src/storage/mod.rsdash-spv/src/sync/filters/download.rsdash-spv/src/sync/filters/headers.rsdash-spv/src/sync/filters/manager.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/sync/filters/requests.rsdash-spv/src/sync/filters/retry.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/sync/headers/manager.rsdash-spv/src/sync/manager.rsdash-spv/src/sync/masternodes/manager.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/sync/post_sync.rskey-wallet-manager/src/wallet_interface.rs
🧰 Additional context used
📓 Path-based instructions (6)
dash-spv/**/*.rs
📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)
dash-spv/**/*.rs: Use async/await throughout the codebase, built on tokio runtime
Use Arc for trait objects to enable runtime polymorphism for NetworkManager and StorageManager
Use Tokio channels for inter-component message passing between async tasks
Maintain minimum Rust version (MSRV) of 1.89 and use only compatible syntax and features
Files:
dash-spv/src/storage/mod.rsdash-spv/src/sync/headers/manager.rsdash-spv/src/sync/masternodes/manager.rsdash-spv/src/network/mod.rsdash-spv/src/client/mempool.rsdash-spv/src/sync/filters/headers.rsdash-spv/src/main.rsdash-spv/src/sync/filters/download.rsdash-spv/src/sync/manager.rsdash-spv/src/client/chainlock.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/sync/filters/requests.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/client/events.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/client/message_handler.rsdash-spv/src/sync/post_sync.rsdash-spv/src/sync/filters/retry.rsdash-spv/src/client/status_display.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rsdash-spv/src/sync/filters/manager.rs
dash-spv/src/storage/**/*.rs
📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)
Store headers in 10,000-header segments with index files in headers/ directory, filter headers and compact block filters in filters/ directory, and state in state/ directory
Files:
dash-spv/src/storage/mod.rs
**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.rs: MSRV (Minimum Supported Rust Version) is 1.89; ensure compatibility with this version for all builds
Unit tests should live alongside code with#[cfg(test)]annotation; integration tests use thetests/directory
Usesnake_casefor function and variable names
UseUpperCamelCasefor types and traits
UseSCREAMING_SNAKE_CASEfor constants
Format code withrustfmtbefore commits; ensurecargo fmt --allis run
Runcargo clippy --workspace --all-targets -- -D warningsfor linting; avoid warnings in CI
Preferasync/awaitviatokiofor asynchronous operations
**/*.rs: Never hardcode network parameters, addresses, or keys in Rust code
Use proper error types (thiserror) and propagate errors appropriately in Rust
Use tokio runtime for async operations in Rust
Use conditional compilation with feature flags for optional features
Write unit tests for new functionality in Rust
Format code using cargo fmt
Run clippy with all features and all targets, treating warnings as errors
Never log or expose private keys in any code
Always validate inputs from untrusted sources in Rust
Use secure random number generation for keys
Files:
dash-spv/src/storage/mod.rsdash-spv/src/sync/headers/manager.rsdash-spv/src/sync/masternodes/manager.rsdash-spv/src/network/mod.rsdash-spv/src/client/mempool.rsdash-spv/src/sync/filters/headers.rsdash-spv/src/main.rsdash-spv/src/sync/filters/download.rsdash-spv/src/sync/manager.rsdash-spv/src/client/chainlock.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/sync/filters/requests.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/client/events.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/client/message_handler.rsdash-spv/src/sync/post_sync.rsdash-spv/src/sync/filters/retry.rsdash-spv/src/client/status_display.rskey-wallet-manager/src/wallet_interface.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rsdash-spv/src/sync/filters/manager.rs
dash-spv/src/sync/**/*.rs
📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)
Implement sequential phase-based synchronization via SyncManager with phases progressing in order: Headers → Masternode List → Filter Headers → Filters → Blocks
Files:
dash-spv/src/sync/headers/manager.rsdash-spv/src/sync/masternodes/manager.rsdash-spv/src/sync/filters/headers.rsdash-spv/src/sync/filters/download.rsdash-spv/src/sync/manager.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/sync/filters/requests.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/sync/post_sync.rsdash-spv/src/sync/filters/retry.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/sync/filters/manager.rs
dash-spv/src/network/**/*.rs
📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)
dash-spv/src/network/**/*.rs: Use DNS-first peer discovery with automatic DNS seeds (dnsseed.dash.org, testnet-seed.dashdot.io) when no explicit peers are configured; implement immediate startup with 10-second delay only for subsequent peer searches
Implement configurable timeouts with recovery mechanisms for network operations
Files:
dash-spv/src/network/mod.rs
dash-spv/src/client/**/*.rs
📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)
Use the DashSpvClient high-level API with proper configuration via ClientConfig for client initialization
Files:
dash-spv/src/client/mempool.rsdash-spv/src/client/chainlock.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/client/events.rsdash-spv/src/client/message_handler.rsdash-spv/src/client/status_display.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rs
🧠 Learnings (28)
📓 Common learnings
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T15:54:02.509Z
Learning: The `StorageManager` trait in `dash-spv/src/storage/mod.rs` uses `&mut self` methods but is also `Send + Sync`, and implementations often use interior mutability for concurrency. This can be confusing, so explicit documentation should clarify thread-safety expectations and the rationale for the API design.
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/**/*.rs : Use Arc<dyn TraitName> for trait objects to enable runtime polymorphism for NetworkManager and StorageManager
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T16:02:42.390Z
Learning: Passing exclusive mutable references to network and storage managers into the sync manager in async Rust can lead to borrow checker issues or runtime contention if concurrent access is needed elsewhere. It's advisable to document this architectural tradeoff and consider refactoring to interior mutability or message passing for shared access as the codebase evolves.
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Separate immutable structures (`Account`, `Wallet`) containing only identity information from mutable wrappers (`ManagedAccount`, `ManagedWalletInfo`) with state management
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/managed_account/**/*.rs : Implement atomic state updates when processing transactions: update transactions, UTXOs, balances, and address usage state together
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Use `BTreeMap` for ordered data (accounts, transactions) and `HashMap` for lookups (address mappings); apply memory management strategies for old transaction data
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Use the `?` operator for error propagation, provide context in error messages, never panic in library code, and return `Result<T>` for all fallible operations
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Apply atomic state updates when managing watch-only wallets: validate that external signatures match expected pubkeys and never attempt signing operations
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: When adding new features, define traits for abstractions, implement concrete types following existing patterns, add comprehensive unit tests, add integration tests for network interaction, and update error types in error.rs
📚 Learning: 2025-06-26T15:54:02.509Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T15:54:02.509Z
Learning: The `StorageManager` trait in `dash-spv/src/storage/mod.rs` uses `&mut self` methods but is also `Send + Sync`, and implementations often use interior mutability for concurrency. This can be confusing, so explicit documentation should clarify thread-safety expectations and the rationale for the API design.
Applied to files:
dash-spv/src/storage/mod.rsdash-spv/src/sync/headers/manager.rsdash-spv/src/sync/masternodes/manager.rsdash-spv/src/network/mod.rsdash-spv/src/client/mempool.rsdash-spv/src/sync/filters/headers.rsdash-spv/src/main.rsdash-spv/src/sync/filters/download.rsdash-spv/src/sync/manager.rsdash-spv/src/client/chainlock.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/sync/filters/requests.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/client/events.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/client/message_handler.rsdash-spv/src/sync/post_sync.rsdash-spv/src/sync/filters/retry.rsdash-spv/src/client/status_display.rskey-wallet-manager/src/wallet_interface.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rsdash-spv/src/sync/filters/manager.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/**/*.rs : Use Arc<dyn TraitName> for trait objects to enable runtime polymorphism for NetworkManager and StorageManager
Applied to files:
dash-spv/src/storage/mod.rsdash-spv/src/sync/headers/manager.rsdash-spv/src/sync/masternodes/manager.rsdash-spv/src/network/mod.rsdash-spv/src/client/mempool.rsdash-spv/src/sync/filters/headers.rsdash-spv/src/main.rsdash-spv/src/sync/filters/download.rsdash-spv/src/sync/manager.rsdash-spv/src/client/chainlock.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/sync/filters/requests.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/client/events.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/client/message_handler.rsdash-spv/src/sync/post_sync.rsdash-spv/src/sync/filters/retry.rsdash-spv/src/client/status_display.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rsdash-spv/src/sync/filters/manager.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Use thread-local storage for error propagation via `dash_spv_ffi_get_last_error()` function
Applied to files:
dash-spv/src/storage/mod.rsdash-spv/src/main.rsdash-spv/src/client/chainlock.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/**/*.rs : Maintain minimum Rust version (MSRV) of 1.89 and use only compatible syntax and features
Applied to files:
dash-spv/src/storage/mod.rsdash-spv/src/sync/headers/manager.rsdash-spv/src/sync/masternodes/manager.rsdash-spv/src/network/mod.rsdash-spv/src/client/mempool.rsdash-spv/src/main.rsdash-spv/src/sync/filters/download.rsdash-spv/src/sync/manager.rsdash-spv/src/client/chainlock.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/sync/filters/requests.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/client/events.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/client/message_handler.rsdash-spv/src/client/status_display.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rsdash-spv/src/sync/filters/manager.rs
📚 Learning: 2025-06-26T16:02:42.390Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T16:02:42.390Z
Learning: Passing exclusive mutable references to network and storage managers into the sync manager in async Rust can lead to borrow checker issues or runtime contention if concurrent access is needed elsewhere. It's advisable to document this architectural tradeoff and consider refactoring to interior mutability or message passing for shared access as the codebase evolves.
Applied to files:
dash-spv/src/storage/mod.rsdash-spv/src/sync/headers/manager.rsdash-spv/src/sync/masternodes/manager.rsdash-spv/src/network/mod.rsdash-spv/src/sync/filters/headers.rsdash-spv/src/sync/filters/download.rsdash-spv/src/sync/manager.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/sync/filters/requests.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/sync/post_sync.rsdash-spv/src/sync/filters/retry.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/sync/filters/manager.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/**/*.rs : Use async/await throughout the codebase, built on tokio runtime
Applied to files:
dash-spv/src/storage/mod.rsdash-spv/src/sync/headers/manager.rsdash-spv/src/sync/masternodes/manager.rsdash-spv/src/network/mod.rsdash-spv/src/client/mempool.rsdash-spv/src/main.rsdash-spv/src/sync/manager.rsdash-spv/src/client/chainlock.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/sync/filters/requests.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/client/events.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/client/message_handler.rsdash-spv/src/sync/post_sync.rsdash-spv/src/client/status_display.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/sync/**/*.rs : Implement sequential phase-based synchronization via SyncManager with phases progressing in order: Headers → Masternode List → Filter Headers → Filters → Blocks
Applied to files:
dash-spv/src/storage/mod.rsdash-spv/src/sync/headers/manager.rsdash-spv/src/sync/masternodes/manager.rsdash-spv/src/network/mod.rsdash-spv/src/client/mempool.rsdash-spv/src/sync/filters/headers.rsdash-spv/src/main.rsdash-spv/src/sync/filters/download.rsdash-spv/src/sync/manager.rsdash-spv/src/client/chainlock.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/sync/filters/requests.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/client/events.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/client/message_handler.rsdash-spv/src/sync/post_sync.rsdash-spv/src/sync/filters/retry.rskey-wallet-manager/src/wallet_interface.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rsdash-spv/src/sync/filters/manager.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Rust strings must be returned as `*const c_char` with caller responsibility to free using `dash_string_free`
Applied to files:
dash-spv/src/storage/mod.rsdash-spv/src/main.rsdash-spv/src/client/progress.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/storage/**/*.rs : Store headers in 10,000-header segments with index files in headers/ directory, filter headers and compact block filters in filters/ directory, and state in state/ directory
Applied to files:
dash-spv/src/storage/mod.rsdash-spv/src/sync/headers/manager.rsdash-spv/src/sync/filters/headers.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/error.rs : Use domain-specific error types (NetworkError, StorageError, SyncError, ValidationError, SpvError) rather than generic error handling
Applied to files:
dash-spv/src/storage/mod.rsdash-spv/src/sync/masternodes/manager.rsdash-spv/src/client/mempool.rsdash-spv/src/sync/filters/headers.rsdash-spv/src/main.rsdash-spv/src/sync/filters/download.rsdash-spv/src/sync/manager.rsdash-spv/src/client/chainlock.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/sync/filters/requests.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/client/events.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/client/message_handler.rsdash-spv/src/sync/post_sync.rsdash-spv/src/sync/filters/retry.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/network/**/*.rs : Use DNS-first peer discovery with automatic DNS seeds (dnsseed.dash.org, testnet-seed.dashdot.io) when no explicit peers are configured; implement immediate startup with 10-second delay only for subsequent peer searches
Applied to files:
dash-spv/src/network/mod.rsdash-spv/src/client/mempool.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/network/**/*.rs : Implement configurable timeouts with recovery mechanisms for network operations
Applied to files:
dash-spv/src/network/mod.rsdash-spv/src/client/mempool.rsdash-spv/src/client/chainlock.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/client/events.rsdash-spv/src/sync/filters/retry.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Use trait-based abstractions (NetworkManager, StorageManager) for swappable implementations instead of concrete types
Applied to files:
dash-spv/src/network/mod.rsdash-spv/src/sync/filters/headers.rsdash-spv/src/sync/filters/matching.rsdash-spv/src/sync/filters/stats.rs
📚 Learning: 2025-06-26T16:01:37.609Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 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/src/client/mempool.rsdash-spv/src/client/chainlock.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/sync/filters/stats.rsdash-spv/src/client/events.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/client/**/*.rs : Use the DashSpvClient high-level API with proper configuration via ClientConfig for client initialization
Applied to files:
dash-spv/src/client/mempool.rsdash-spv/src/main.rsdash-spv/src/client/chainlock.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/client/events.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/validation/**/*.rs : Implement three validation modes: ValidationMode::None (no validation), ValidationMode::Basic (structure and timestamp validation), and ValidationMode::Full (complete PoW and chain validation)
Applied to files:
dash-spv/src/client/mempool.rsdash-spv/src/client/chainlock.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/queries.rsdash-spv/src/sync/phase_execution.rsdash-spv/src/client/transactions.rsdash-spv/src/client/core.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/**/*.rs : Use Tokio channels for inter-component message passing between async tasks
Applied to files:
dash-spv/src/client/mempool.rsdash-spv/src/main.rsdash-spv/src/client/chainlock.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/block_processor.rsdash-spv/src/client/lifecycle.rsdash-spv/src/client/queries.rsdash-spv/src/client/events.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/client/message_handler.rsdash-spv/src/client/progress.rsdash-spv/src/client/transactions.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Separate immutable structures (`Account`, `Wallet`) containing only identity information from mutable wrappers (`ManagedAccount`, `ManagedWalletInfo`) with state management
Applied to files:
dash-spv/src/sync/manager.rsdash-spv/src/sync/message_handlers.rsdash-spv/src/client/status_display.rskey-wallet-manager/src/wallet_interface.rs
📚 Learning: 2025-11-27T10:30:54.015Z
Learnt from: xdustinface
Repo: dashpay/rust-dashcore PR: 214
File: dash-spv/examples/filter_sync.rs:48-51
Timestamp: 2025-11-27T10:30:54.015Z
Learning: The DashSpvClient::run method in dash-spv internally handles Ctrl-C shutdown by spawning a task that listens for tokio::signal::ctrl_c() and cancels the provided CancellationToken. Examples and callers should create a CancellationToken without explicitly cancelling it, as the cancellation is managed internally by the run method.
Applied to files:
dash-spv/src/client/chainlock.rsdash-spv/src/client/sync_coordinator.rsdash-spv/src/client/events.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Add cbindgen annotations for complex types in FFI functions
Applied to files:
dash-spv/src/sync/filters/stats.rsdash-spv/src/client/events.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/managed_account/**/*.rs : Implement atomic state updates when processing transactions: update transactions, UTXOs, balances, and address usage state together
Applied to files:
dash-spv/src/sync/post_sync.rskey-wallet-manager/src/wallet_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Apply atomic state updates when managing watch-only wallets: validate that external signatures match expected pubkeys and never attempt signing operations
Applied to files:
key-wallet-manager/src/wallet_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/address_pool/**/*.rs : Support multiple `KeySource` variants (Private, Public, NoKeySource) to enable both full wallets and watch-only wallets with the same interface
Applied to files:
key-wallet-manager/src/wallet_interface.rs
📚 Learning: 2025-08-21T05:01:58.949Z
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 108
File: key-wallet-ffi/src/wallet_manager.rs:270-318
Timestamp: 2025-08-21T05:01:58.949Z
Learning: In the key-wallet-ffi design, wallets retrieved from the wallet manager via lookup functions should return const pointers (*const FFIWallet) to enforce read-only access and prevent unintended modifications. The wallet manager should control wallet lifecycle and mutations through specific APIs rather than allowing external mutation of retrieved wallet references.
Applied to files:
key-wallet-manager/src/wallet_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Use `BTreeMap` for ordered data (accounts, transactions) and `HashMap` for lookups (address mappings); apply memory management strategies for old transaction data
Applied to files:
key-wallet-manager/src/wallet_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/account/**/*.rs : Use enum-based type system for `AccountType` with specific variants (Standard, IdentityAuthentication, IdentityEncryption, MasternodeOperator, etc.) to provide compile-time safety and clear semantics
Applied to files:
key-wallet-manager/src/wallet_interface.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Use the `?` operator for error propagation, provide context in error messages, never panic in library code, and return `Result<T>` for all fallible operations
Applied to files:
key-wallet-manager/src/wallet_interface.rs
🧬 Code graph analysis (1)
dash-spv/src/main.rs (1)
dash-spv/src/client/core.rs (1)
storage(163-165)
🔇 Additional comments (28)
dash-spv/src/sync/filters/retry.rs (1)
15-15: LGTM! Bounds successfully moved to trait definitions.The removal of
+ Send + Sync + 'staticfrom the impl block is correct since these bounds are now enforced by theStorageManagerandNetworkManagertrait definitions themselves. This reduces repetition and improves maintainability.dash-spv/src/client/sync_coordinator.rs (1)
26-26: LGTM! Simplified impl bounds are cleaner and maintain correctness.The bounds
Send + Sync + 'staticare now inherited from the trait definitions (WalletInterface,NetworkManager,StorageManager), so removing them here eliminates redundancy while maintaining the same compile-time guarantees.key-wallet-manager/src/wallet_interface.rs (1)
13-13: LGTM! Adding'staticbound is correct for trait object compatibility.Adding
'staticto theWalletInterfacetrait definition is appropriate given that this trait is used withArc<dyn WalletInterface>for runtime polymorphism throughout the codebase. This change enables the removal of redundant bounds at call sites.Note: This is a breaking change for trait implementors that aren't
'static, but this is intentional and aligns with the async/Arc<dyn>usage patterns in the codebase.Based on learnings, the codebase uses
Arc<dyn TraitName>for trait objects.dash-spv/src/client/mempool.rs (1)
20-20: LGTM! Consistent bound simplification across client modules.The removal of redundant bounds follows the same pattern as other client modules, successfully leveraging the
'staticrequirements now defined on the traits themselves.dash-spv/src/network/mod.rs (1)
31-31: LGTM! NetworkManager trait bound updated consistently with WalletInterface.Adding
'statictoNetworkManagerfollows the same pattern asWalletInterfaceand is appropriate for a trait used withArc<dyn NetworkManager>throughout the codebase. Verified thatStorageManageralready has the'staticbound and all impl blocks use simplified generic constraints without redundant trait bounds.dash-spv/src/sync/filters/headers.rs (1)
29-29: LGTM: Redundant bounds correctly removed.The generic bounds are now inherited from the trait definitions themselves (
StorageManagerandNetworkManagertraits now include'static), eliminating the need to repeat them here. This is the intended outcome of the refactoring.dash-spv/src/sync/masternodes/manager.rs (1)
54-54: LGTM: Bounds correctly simplified.The
Send + Sync + 'staticbounds are now inherited from the trait definitions, making this impl block cleaner and more maintainable.dash-spv/src/main.rs (1)
350-350: LGTM: Function signature simplified correctly.The bounds are now inherited from the
StorageManagertrait definition, making the function signature cleaner without losing any safety guarantees.dash-spv/src/client/block_processor.rs (1)
41-41: LGTM: Impl bounds correctly streamlined.The
Send + Sync + 'staticrequirements are now enforced by the trait definitions (WalletInterfaceandStorageManager), eliminating redundancy. This is particularly important here sinceBlockProcessorstores these types inArc<RwLock<W>>andArc<Mutex<S>>, which require'static.dash-spv/src/sync/phase_execution.rs (1)
13-13: Clean refactoring of trait bounds.The removal of
Send + Sync + 'staticbounds from the impl block is correct since these bounds are now enforced at the trait definition level forStorageManager,NetworkManager, andWalletInterface. This maintains the same guarantees while reducing repetition.dash-spv/src/sync/manager.rs (1)
103-103: LGTM!The impl bound simplification aligns with the trait definition changes. The struct's use of
Arc<RwLock<W>>for the wallet and stats fields will continue to work correctly since theSend + Sync + 'staticrequirements are now encoded in theWalletInterfacetrait definition itself.dash-spv/src/client/queries.rs (1)
22-22: LGTM!The simplified bounds are appropriate for this query-focused impl block. The
Send + Sync + 'staticrequirements are now enforced by the trait definitions, maintaining thread-safety guarantees for the underlying types.dash-spv/src/client/status_display.rs (1)
26-26: LGTM!The bound simplification is correct. Note that the
try_get_balance_if_anyhelper method (line 151-175) has a localW: 'staticconstraint, which is now always satisfied sinceWalletInterfaceincludes'staticin its trait definition. This maintains theTypeId-based downcasting functionality.dash-spv/src/sync/filters/download.rs (1)
24-24: LGTM!The trait bound simplification for
FilterSyncManageris consistent with the PR's objective. The async filter download and verification methods will continue to work correctly as theSend + Sync + 'staticrequirements are now part of theStorageManagerandNetworkManagertrait definitions.dash-spv/src/sync/filters/requests.rs (1)
14-14: LGTM!The simplified impl bounds are correct. The request queue management and flow control logic remains unchanged, with
Send + Sync + 'staticrequirements now enforced at the trait definition level.dash-spv/src/sync/filters/stats.rs (1)
7-7: LGTM!The bound simplification for the statistics impl block is consistent with the overall refactoring. These are simple synchronous accessor methods that don't require any changes beyond the bound relaxation.
dash-spv/src/client/transactions.rs (1)
11-11: Impl bounds correctly simplified.The removal of
+ Send + Sync + 'staticfrom the generic parameters is correct since these bounds are now part of the trait definitions themselves. This reduces repetition while maintaining the same constraints.dash-spv/src/client/lifecycle.rs (1)
28-28: Impl bounds correctly simplified.The relaxed bounds align with the trait-level enforcement. The async patterns (spawning tasks with
tokio::spawnat line 148, usingArc<RwLock<W>>andArc<Mutex<S>>) continue to work correctly becauseWalletInterface,NetworkManager, andStorageManagernow includeSend + Sync + 'staticin their definitions.dash-spv/src/client/message_handler.rs (1)
27-27: Impl bounds correctly simplified.
MessageHandleruses borrowed references (&'a mut) rather than owned trait objects, so the relaxed impl bounds are appropriate. TheSend + Sync + 'staticrequirements are now enforced at the trait definition level.dash-spv/src/client/events.rs (1)
16-16: Impl bounds correctly simplified.The event handling methods use channel operations that don't require additional bounds beyond what the trait definitions now provide.
dash-spv/src/sync/post_sync.rs (1)
16-16: Impl bounds correctly simplified.The post-sync handlers use mutable references to network and storage managers. The relaxed bounds are correct since
StorageManager,NetworkManager, andWalletInterfacetraits now include the necessary bounds in their definitions.dash-spv/src/client/progress.rs (1)
17-17: Impl bounds correctly simplified.Progress tracking and statistics methods use standard async patterns with mutex-guarded storage access. The trait-level bounds are sufficient for these operations.
dash-spv/src/sync/headers/manager.rs (1)
64-64: Impl bounds correctly simplified.
HeaderSyncManagerusesPhantomDatamarkers for type parameters and takes mutable references to storage/network managers. The relaxed impl bounds are correct since the trait definitions now carry theSend + Sync + 'staticrequirements.dash-spv/src/sync/message_handlers.rs (1)
19-19: Consistent trait bound simplification.The impl header correctly removes redundant
Send + Sync + 'staticbounds on S, N, and W, relying on the trait definitions to provide these constraints.dash-spv/src/sync/filters/matching.rs (1)
22-22: Bounds correctly simplified.The generic bounds have been appropriately reduced to rely on the trait definitions for
Send + Sync + 'staticrequirements.dash-spv/src/client/core.rs (1)
149-149: Generic bounds properly simplified.The impl block correctly removes redundant trait bounds while maintaining the same effective constraints through the trait definitions. The extensive documentation about the generic design philosophy remains accurate since the architectural approach is unchanged.
dash-spv/src/client/chainlock.rs (1)
19-19: Refactoring completed consistently.The impl signature follows the same clean simplification pattern as the rest of the codebase, removing redundant
Send + Sync + 'staticbounds.dash-spv/src/sync/filters/manager.rs (1)
89-89: Trait bound refactoring is complete and correct.The
StorageManagerandNetworkManagertrait definitions properly include theSend + Sync + 'staticbounds, and all implementation blocks across the codebase—includingFilterSyncManager,SyncManager,HeaderSyncManager, andMasternodeSyncManager—correctly reference the traits without redundant bound repetition. This approach reduces boilerplate, follows the DRY principle, and is consistent across all implementations in the codebase.
These bounds are required almost everywhere anyway, so making them explicit in the trait definitions reduces lots of repetitions.
'statictoStorageManager,NetworkManager, andWalletInterfacetraitsSummary by CodeRabbit
Refactor
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.