Skip to content

refactor: simplify HandshakeManager to accept relay#533

Open
xdustinface wants to merge 1 commit intov0.42-devfrom
refactor/cleanup-handshake-relay
Open

refactor: simplify HandshakeManager to accept relay#533
xdustinface wants to merge 1 commit intov0.42-devfrom
refactor/cleanup-handshake-relay

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Mar 13, 2026

Summary by CodeRabbit

  • Refactor
    • Simplified the network handshake configuration mechanism by replacing a strategy parameter with a relay toggle flag, reducing API complexity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 530f9c99-08e1-4d14-86fc-55423d73bb3b

📥 Commits

Reviewing files that changed from the base of the PR and between 33eb7b8 and 363b42d.

📒 Files selected for processing (4)
  • dash-spv/src/network/handshake.rs
  • dash-spv/src/network/manager.rs
  • dash-spv/tests/handshake_test.rs
  • dash-spv/tests/test_handshake_logic.rs

📝 Walkthrough

Walkthrough

The HandshakeManager struct and constructor signature were refactored to replace the MempoolStrategy enum parameter with a simpler boolean relay flag. The change propagates through the codebase, updating the implementation, all call sites, and corresponding test cases.

Changes

Cohort / File(s) Summary
Core Implementation
dash-spv/src/network/handshake.rs
Replaced mempool_strategy: MempoolStrategy field with relay: bool in HandshakeManager struct. Updated constructor signature from new(network, mempool_strategy, user_agent) to new(network, relay, user_agent). Simplified Version message construction to set relay directly from self.relay.
Call Site Update
dash-spv/src/network/manager.rs
Updated HandshakeManager instantiation in PeerNetworkManager::connect_to_peer to pass relay boolean (computed as self.mempool_strategy != BloomFilter) instead of mempool_strategy enum variant.
Test Updates
dash-spv/tests/handshake_test.rs, dash-spv/tests/test_handshake_logic.rs
Updated HandshakeManager constructor calls in tests to pass boolean relay flag instead of MempoolStrategy variant. Removed MempoolStrategy imports from test files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

A rabbit hops through code so neat,
"MempoolStrategy," we must defeat!
A boolean relay shines bright and clean,
Simplicity's the best we've seen! 🐇✨
Less enum fuss, more elegant flow,
Watch the refactor steal the show!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: simplify HandshakeManager to accept relay' accurately describes the main change: replacing MempoolStrategy parameter with a boolean relay flag across HandshakeManager and related code.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/cleanup-handshake-relay
📝 Coding Plan
  • Generate coding plan for human review 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.

❤️ Share

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

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.89%. Comparing base (33eb7b8) to head (363b42d).

Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #533      +/-   ##
=============================================
- Coverage      66.91%   66.89%   -0.02%     
=============================================
  Files            313      313              
  Lines          64741    64738       -3     
=============================================
- Hits           43321    43309      -12     
- Misses         21420    21429       +9     
Flag Coverage Δ *Carryforward flag
core 75.02% <ø> (ø)
dash-network 75.00% <ø> (ø) Carriedforward from 33eb7b8
dash-network-ffi 34.76% <ø> (ø) Carriedforward from 33eb7b8
dash-spv 68.28% <ø> (+0.01%) ⬆️ Carriedforward from 33eb7b8
dash-spv-ffi 34.76% <ø> (ø) Carriedforward from 33eb7b8
dashcore 75.00% <ø> (ø) Carriedforward from 33eb7b8
dashcore-private 75.00% <ø> (ø) Carriedforward from 33eb7b8
dashcore-rpc 19.92% <ø> (ø) Carriedforward from 33eb7b8
dashcore-rpc-json 19.92% <ø> (ø) Carriedforward from 33eb7b8
dashcore_hashes 75.00% <ø> (ø) Carriedforward from 33eb7b8
ffi 36.51% <ø> (+0.01%) ⬆️
key-wallet 65.65% <ø> (ø) Carriedforward from 33eb7b8
key-wallet-ffi 34.76% <ø> (ø) Carriedforward from 33eb7b8
key-wallet-manager 65.65% <ø> (ø) Carriedforward from 33eb7b8
rpc 19.92% <ø> (ø)
spv 81.10% <100.00%> (-0.10%) ⬇️
wallet 65.68% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
dash-spv/src/network/handshake.rs 78.88% <100.00%> (+0.35%) ⬆️
dash-spv/src/network/manager.rs 58.48% <100.00%> (-0.30%) ⬇️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant