fix(wallet): improve account and wallet model handling#610
Conversation
- Enhance DSAccount with better transaction tracking - Improve DSWallet for multi-account support - Better balance calculation and cache management - Enhanced property accessors for improved performance
📝 WalkthroughWalkthroughAdds a ChangesLocked Balance Feature
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant DSWallet
participant DSAccount
participant DerivationPath
DSAccount->>DSAccount: updateBalance()
DSAccount->>DerivationPath: check if output address is controlled
DerivationPath-->>DSAccount: ownership result
DSAccount->>DSAccount: accumulate lockedBalance
DSAccount->>DSAccount: update _lockedBalance, evaluate balanceChanged/lockedChanged
DSAccount->>DSAccount: post notification if changed
DSWallet->>DSAccount: request lockedBalance per account
DSAccount-->>DSWallet: return lockedBalance
DSWallet->>DSWallet: sum lockedBalance across accounts
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
DashSync/shared/Models/Wallet/DSAccount.m (1)
745-753: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueNested output/derivation-path scan; consider reusing an existing ownership lookup.
For every immature transaction, this does an O(outputs × fundDerivationPaths) linear scan via
containsAddress:per output. If the balance loop elsewhere already has a faster/cached way to check output ownership (e.g., a hash-set of owned addresses or an existing UTXO ownership check), reusing it here would avoid duplicating the ownership-check logic and keep the two computations consistent.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@DashSync/shared/Models/Wallet/DSAccount.m` around lines 745 - 753, The immature-transaction balance path in DSAccount.m is still doing a nested scan over tx.outputs and self.fundDerivationPaths via containsAddress:, which duplicates ownership logic and is unnecessarily slow. Update this loop to reuse the same cached/faster ownership check used elsewhere in the balance calculation (for example, an owned-address set or existing UTXO ownership helper) so output ownership is determined once and consistently in the same way as the rest of the balance code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@DashSync/shared/Models/Wallet/DSAccount.m`:
- Around line 745-753: The immature-transaction balance path in DSAccount.m is
still doing a nested scan over tx.outputs and self.fundDerivationPaths via
containsAddress:, which duplicates ownership logic and is unnecessarily slow.
Update this loop to reuse the same cached/faster ownership check used elsewhere
in the balance calculation (for example, an owned-address set or existing UTXO
ownership helper) so output ownership is determined once and consistently in the
same way as the rest of the balance code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 436898f3-e60f-4d99-8af6-9cfd9ce83896
📒 Files selected for processing (4)
DashSync/shared/Models/Wallet/DSAccount.hDashSync/shared/Models/Wallet/DSAccount.mDashSync/shared/Models/Wallet/DSWallet.hDashSync/shared/Models/Wallet/DSWallet.m
Issue being fixed or feature implemented
Enhances the core wallet infrastructure to support better transaction tracking, multi-account operations, and improve performance. These changes address performance bottlenecks in balance calculation and property access while laying the groundwork for multi-account wallet support.
What was done?
How Has This Been Tested?
Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
New Features
Bug Fixes