Skip to content

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Feb 5, 2026

Don't return optionals, it's not really needed. And remove duplicated getters.

Summary by CodeRabbit

  • Refactor
    • Improved internal storage access patterns for enhanced consistency and maintainability across the application's data layer.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

The PR refactors the storage access API from optional accessor methods returning Option<Arc<RwLock<...>>> to mandatory methods returning Arc<RwLock<...>>. This consolidates storage access patterns across the codebase. The StorageManager trait is updated with new methods, and all callsites (lifecycle initialization and tests) are adjusted to use the new accessors.

Changes

Cohort / File(s) Summary
Storage API Refactoring
dash-spv/src/storage/mod.rs
Replaced optional accessor methods (header_storage_ref, filter_header_storage_ref, filter_storage_ref, block_storage_ref) with direct methods (block_headers, filter_headers, filters, blocks). Removed direct public getters from DiskStorageManager implementation. Updated trait to return Arc<RwLock<...>> directly instead of wrapped in Option.
Client Lifecycle Updates
dash-spv/src/client/lifecycle.rs
Refactored initialization to use new storage accessors: replaced header_storage variable with storage.block_headers(), storage.filter_headers(), storage.filters(), and storage.blocks() across BlockHeadersManager, FilterHeadersManager, FiltersManager, BlocksManager, and MasternodesManager constructors.
Sync Manager Tests
dash-spv/src/sync/block_headers/manager.rs, dash-spv/src/sync/blocks/manager.rs, dash-spv/src/sync/chainlock/manager.rs, dash-spv/src/sync/filter_headers/manager.rs, dash-spv/src/sync/filters/manager.rs, dash-spv/src/sync/masternodes/manager.rs
Updated test modules to import StorageManager and use new storage accessor methods instead of deprecated ones. Changed all test setup to call storage.block_headers(), storage.filter_headers(), storage.filters(), and storage.blocks() where applicable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Storage pathways cleared of ambiguity,
Direct access now, no Option's uncertainty,
Arc and RwLock flow through the light,
Each manager aligned, clean and tight!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: refactoring storage accessor methods in DashSpvClient and related components from optional references to direct Arc<RwLock<...>> returns, eliminating unnecessary wrapping.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/cleaup-storage-usage

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.

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