You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: various notification / statistics and performance improvements (#157)
* Fix missing statistics updates for filter matches and relevant transactions
This commit fixes two statistics tracking issues that were accidentally
omitted during the wallet integration refactoring:
1. filters_matched statistic was not being incremented when filter matches
were detected in sequential sync (sequential/mod.rs:1390-1398)
2. blocks_with_relevant_transactions statistic was not being incremented
when the wallet found relevant transactions in blocks (block_processor.rs:238-242)
Changes:
- Added stats field to SequentialSyncManager struct to enable statistics
updates during filter matching
- Updated SequentialSyncManager::new() to accept stats parameter
- Added filters_matched increment when filter match is detected
- Added blocks_with_relevant_transactions increment when wallet processes
relevant transactions
- Updated DashSpvClient to pass stats when creating SequentialSyncManager
Root cause: These statistics were tracked in old commented-out code
(marked with "TODO: Re-implement with wallet integration") but were never
re-added to the new simplified wallet integration code path.
Result: Statistics now correctly show non-zero values for "Filters Matched"
and "Blocks w/ Relevant Txs" in sync status logs, providing accurate
visibility into sync progress.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add TransactionDetected event emission in block processor
- Emit individual TransactionDetected events for each relevant transaction found in blocks
- Include transaction details: txid, confirmed status, block height, and amount
- Remove excessive debug logging from FFI layer
This enables real-time transaction notifications to Swift layer for wallet balance updates.
* Fix account balance not being updated after transaction processing
Root cause: When processing transactions, UTXOs were correctly added/removed
from accounts, but the account's balance field was never recalculated. This
caused wallet-level balance to be correct (calculated by summing account UTXOs)
while individual account balances remained at zero.
Changes:
- Add balance recalculation after UTXO updates in wallet_checker.rs
- Calculate confirmed/unconfirmed/locked balance from account's UTXO set
- Call account.update_balance() with recalculated values
Impact:
- managed_account_get_balance() FFI now returns correct values
- Multi-account wallets will now show correct per-account balances
- Removes need for Swift workaround of using wallet-level balance
Fixes account balance query returning zero despite correct UTXO state.
* Add support for querying all addresses with (0, 0) range
Allow address_pool_get_addresses_in_range to return all addresses when
called with start_index=0 and end_index=0. This provides a clean way to
retrieve all generated addresses without hardcoding a limit.
Implementation:
- Special case: when start=0 and end=0, iterate from 0 to highest_generated
- Normal case: continue with existing range validation and iteration
- Returns all addresses that exist in the pool, including gap limit buffer
This avoids hardcoding arbitrary limits (like 10000) in client code.
* Add FFI transaction list support for managed accounts
Implement transaction retrieval functionality in key-wallet-ffi to expose
transaction data from managed accounts to client applications.
- Add FFITransactionRecord struct with transaction details (txid, amount, height, etc.)
- Implement managed_account_get_transactions() to retrieve transaction array
- Implement managed_account_free_transactions() for proper memory cleanup
- Update C header with new FFI structures and functions
This enables client applications to display wallet transaction history
with complete transaction information including confirmations, fees,
and transaction types.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* perf(dash-spv): optimize header sync and add parallel CFHeaders flow control
- Add CachedHeader wrapper to eliminate redundant X11 hash computations
during header sync (4-6x reduction in hash operations per header)
- Implement parallel CFHeaders synchronization with flow control, including
request buffering, sequential processing, retry logic, and timeout handling
- Optimize storage operations by accepting precomputed hashes in
store_headers_internal to avoid redundant hash computations
- Reduce disk storage index save frequency to every 10k entries instead of
every periodic save to minimize expensive cloning and serialization
- Use cached hashes throughout validation and storage pipeline in both
headers.rs and headers_with_reorg.rs
- Add configuration options for CFHeaders flow control with sensible defaults:
max_concurrent_cfheaders_requests_parallel (50), cfheaders_request_timeout (30s),
max_cfheaders_retries (3), enable_cfheaders_flow_control (true)
- Remove unused mutable variable in block_processor.rs
These optimizations significantly reduce CPU usage during header sync by
avoiding expensive X11 hash recomputation and enable faster filter header
sync through parallel requests with proper flow control.
* feat(dash-spv): enhance masternode state persistence and synchronization
- Implemented storage of masternode state after sync completion to allow phase manager to detect sync status.
- Updated masternode synchronization logic to use the latest persisted state height for requesting masternode list updates, ensuring accurate base height for ChainLock validation.
- Added logging for potential issues during state persistence and retrieval, improving observability of the synchronization process.
These changes improve the reliability of masternode synchronization and enhance the overall flow control in the dash-spv module.
* docs: update FFI API documentation
* fix: replace Layout::array unwrap with proper error handling in managed_account
Replace the panic-prone unwrap() call on Layout::array with proper error
handling. Now returns false on layout computation failure instead of
panicking at the FFI boundary, improving robustness when handling edge
cases like integer overflow.
* fix: suppress deprecated GenericArray warnings in BIP38 code
Add #[allow(deprecated)] attributes to aes_encrypt and aes_decrypt
functions to suppress CI clippy errors about generic-array 0.14.x
deprecation. The aes crate still requires the old version, making
an upgrade infeasible at this time.
* fix(key-wallet): correct state update flag in transaction routing tests
Fixed two test cases that incorrectly passed Some(&wallet) when
they should have passed None to prevent state updates. The tests
were checking that state is not modified, but were actually
causing updates to occur.
- test_transaction_routing_to_bip32_account: line 167
- test_transaction_affects_multiple_accounts: line 411
All 434 tests now pass.
* fix(dash-spv): add missing CFHeaders flow control fields to test config
Add max_concurrent_cfheaders_requests_parallel, enable_cfheaders_flow_control,
cfheaders_request_timeout_secs, and max_cfheaders_retries fields to the
ClientConfig initialization in network tests to fix compilation error.
* fix(key-wallet-ffi): handle Layout::array overflow safely in deallocator
Replace unwrap() call in managed_account_free_transactions with proper
Result matching. This mirrors the allocation path and prevents potential
panics in FFI context when layout calculation would overflow.
- Match on Layout::array Result instead of unwrap
- Return early if Err to avoid deallocation with invalid layout
- Ensures FFI deallocator is safe and never panics
* refactor: add explicit up-to-date check before computing start_height in CFHeaders request
Skip redundant CFHeaders requests when filter_tip >= stop_height by checking
the up-to-date condition before computing start_height. This avoids unnecessary
height calculations and network requests when the filter is already synced to or
past the target height.
* fix(spv): correct TransactionDetected net_amount via wallet transaction_effect; include affected addresses\n\nfeat(wallet-manager): add WalletInterface::transaction_effect and implement in WalletManager using TransactionRouter and per-account checks\n\ntest(spv): add tests for wallet-provided net, fallback behavior, and negative net with duplicates
* fix: resolve type_complexity clippy warning in block_processor_test
Factor out complex type Arc<Mutex<BTreeMap<Txid, (i64, Vec<String>)>>>
into a type alias TransactionEffectsMap for improved code clarity and
to satisfy clippy type_complexity lint.
---------
Co-authored-by: Claude <[email protected]>
0 commit comments