feat: log wallet events in the client's run loop#525
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds a broadcast-based wallet event subscription across the wallet trait, test mocks, and WalletManager, and wires wallet event reception into the client's sync coordinator loop for runtime logging of wallet events. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as DashSpvClient
participant Wallet as WalletManager
participant Channel as BroadcastChannel
rect rgba(200,220,255,0.5)
Client->>Wallet: subscribe_events()
Wallet->>Channel: return Receiver
end
rect rgba(200,255,200,0.5)
Wallet->>Channel: broadcast WalletEvent (e.g., BalanceUpdated)
Channel-->>Client: deliver WalletEvent
Client->>Client: log WalletEvent
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan for PR comments
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.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@dash-spv/src/client/sync_coordinator.rs`:
- Around line 56-59: The wallet_events.recv() arm currently swallows
RecvError::Lagged and RecvError::Closed; replace the single pattern with a full
match on wallet_events.recv() so you log and handle all cases: on Ok(event) call
tracing::info!("Wallet event: {}", event.description()) and return None as
before; on Err(broadcast::RecvError::Lagged) emit a tracing::warn (include the
lag count if available or at least the error) and return None; on
Err(broadcast::RecvError::Closed) emit tracing::error indicating the
wallet_events channel closed and return None (or take any existing shutdown
behavior). Reference wallet_events.recv(), event.description(), and
RecvError::Lagged/RecvError::Closed in your changes.
In `@key-wallet-manager/src/wallet_interface.rs`:
- Around line 95-96: The new subscription API is unconditionally declared and
uses tokio::sync::broadcast which is std-only while WalletManager::event_sender
is behind #[cfg(feature = "std")]; fix by gating the broadcast import and the
WalletInterface::subscribe_events method with #[cfg(feature = "std")] and ensure
the implementation that calls self.event_sender.subscribe() (the impl block in
wallet_manager/process_block.rs) is also behind #[cfg(feature = "std")] or moved
into a std-only extension trait; reference WalletInterface::subscribe_events,
WalletManager::event_sender, the tokio::sync::broadcast import, and the impl
block in process_block.rs when applying the guards.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9239fb3c-8f14-45e4-87ca-811161922eb2
📒 Files selected for processing (4)
dash-spv/src/client/sync_coordinator.rskey-wallet-manager/src/test_utils/wallet.rskey-wallet-manager/src/wallet_interface.rskey-wallet-manager/src/wallet_manager/process_block.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v0.42-dev #525 +/- ##
=============================================
- Coverage 66.92% 66.92% -0.01%
=============================================
Files 313 313
Lines 64729 64741 +12
=============================================
+ Hits 43322 43329 +7
- Misses 21407 21412 +5
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
Handle and log wallet events in the client's run loop. I think it's good to have when investigating issues from logfiles.
ef3f6c5 to
7742401
Compare
Handle and log wallet events in the client's run loop. I think it's good to have when investigating issues from logfiles.
Summary by CodeRabbit