Skip to content

refactor(dash-spv): drop description(), use Display for events#758

Open
xdustinface wants to merge 1 commit into
v0.42-devfrom
refactor/drop-event-description
Open

refactor(dash-spv): drop description(), use Display for events#758
xdustinface wants to merge 1 commit into
v0.42-devfrom
refactor/drop-event-description

Conversation

@xdustinface
Copy link
Copy Markdown
Collaborator

@xdustinface xdustinface commented May 12, 2026

Fold the inherent description() -> String methods on SyncEvent, NetworkEvent, and WalletEvent into their Display::fmt bodies, and update every caller to format the event directly ({event} instead of {event.description()}). write! replaces the per-arm format! to avoid the intermediate String allocation.

Output is byte-for-byte identical. No new public API, just the existing Display impl carrying the formatting instead of a parallel inherent method.

Summary by CodeRabbit

  • Refactor
    • Consolidated and standardized event logging formatting across network, synchronization, and wallet management modules to improve code consistency and maintainability.
    • Refactored event rendering implementations throughout the codebase to eliminate redundancy and enhance overall code organization.
    • No functional changes or impacts to user-facing features.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 72000c1b-16e1-406c-85d8-cb98c3a0f5aa

📥 Commits

Reviewing files that changed from the base of the PR and between 5297d61 and 6d63e9d.

📒 Files selected for processing (8)
  • dash-spv/src/network/event.rs
  • dash-spv/src/network/manager.rs
  • dash-spv/src/sync/events.rs
  • dash-spv/src/sync/sync_manager.rs
  • dash-spv/tests/dashd_masternode/helpers.rs
  • dash-spv/tests/dashd_sync/helpers.rs
  • dash-spv/tests/dashd_sync/tests_restart.rs
  • key-wallet-manager/src/events.rs

📝 Walkthrough

Walkthrough

Three event types—NetworkEvent, SyncEvent, and WalletEvent—are refactored to implement fmt::Display directly instead of providing public description() helper methods. All logging call sites across main code and tests are updated to format events via the Display trait.

Changes

Event Display Trait Refactoring

Layer / File(s) Summary
NetworkEvent Display implementation and logging update
dash-spv/src/network/event.rs, dash-spv/src/network/manager.rs
NetworkEvent removes description() and implements fmt::Display directly for PeerConnected, PeerDisconnected, and PeersUpdated (with best_height defaulting to 0 when None). Network manager's debug log updates to format the event directly.
SyncEvent Display implementation and logging updates
dash-spv/src/sync/events.rs, dash-spv/src/sync/sync_manager.rs
SyncEvent removes description() and implements fmt::Display directly via match/write! arms for all variants, including conditional formatting for MasternodeStateUpdated based on qr_info_result. Three logging call sites in sync_manager are updated to format events directly instead of calling description().
WalletEvent Display implementation and logging updates
key-wallet-manager/src/events.rs, dash-spv/tests/dashd_masternode/helpers.rs, dash-spv/tests/dashd_sync/helpers.rs, dash-spv/tests/dashd_sync/tests_restart.rs
WalletEvent removes description() and implements fmt::Display directly via match/write! arms computing totals from variant fields. Test helpers and restart test update wallet event logging calls to use the Display trait instead of description().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Events hop from description() to Display so bright,
Formatting straight through traits, what a sight!
Network, sync, and wallet all align,
Logging refactored—tests and code combine,
Cleaner Rust patterns, shining fine.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: removing description() methods and consolidating event formatting into Display implementations across multiple event types.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/drop-event-description

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 59.09091% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.25%. Comparing base (5297d61) to head (6d63e9d).

Files with missing lines Patch % Lines
key-wallet-manager/src/events.rs 0.00% 17 Missing ⚠️
dash-spv/src/sync/events.rs 95.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #758      +/-   ##
=============================================
- Coverage      72.26%   72.25%   -0.02%     
=============================================
  Files            320      320              
  Lines          70275    70274       -1     
=============================================
- Hits           50785    50777       -8     
- Misses         19490    19497       +7     
Flag Coverage Δ
core 76.30% <ø> (ø)
ffi 46.10% <ø> (+0.01%) ⬆️
rpc 20.00% <ø> (ø)
spv 89.70% <96.29%> (-0.06%) ⬇️
wallet 71.26% <0.00%> (ø)
Files with missing lines Coverage Δ
dash-spv/src/network/event.rs 100.00% <100.00%> (ø)
dash-spv/src/network/manager.rs 69.02% <100.00%> (-0.64%) ⬇️
dash-spv/src/sync/sync_manager.rs 73.21% <ø> (ø)
dash-spv/src/sync/events.rs 93.61% <95.00%> (+0.13%) ⬆️
key-wallet-manager/src/events.rs 67.47% <0.00%> (ø)

... and 2 files with indirect coverage changes

@xdustinface xdustinface requested a review from ZocoLini May 12, 2026 10:24
@xdustinface xdustinface added the ready-for-review CodeRabbit has approved this PR label May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@github-actions github-actions Bot added the merge-conflict The PR conflicts with the target branch. label May 12, 2026
Fold the inherent `description() -> String` methods on `SyncEvent`, `NetworkEvent`, and `WalletEvent` into their `Display::fmt` bodies, and update every caller to format the event directly (`{event}` instead of `{event.description()}`). `write!` replaces the per-arm `format!` to avoid the intermediate `String` allocation.

Output is byte-for-byte identical. No new public API, just the existing `Display` impl carrying the formatting instead of a parallel inherent method.
@xdustinface xdustinface force-pushed the refactor/drop-event-description branch from 6d1b610 to 6d63e9d Compare May 13, 2026 08:36
@github-actions github-actions Bot removed the merge-conflict The PR conflicts with the target branch. label May 13, 2026
@github-actions github-actions Bot added ready-for-review CodeRabbit has approved this PR and removed ready-for-review CodeRabbit has approved this PR labels May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review CodeRabbit has approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant