Skip to content

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Jan 29, 2026

Move out FilterHeadersStorage and PersistentFilterHeadersStorage into storage/filters.rs to have one storage type per file.

Summary by CodeRabbit

  • Refactor
    • Reorganized filter header storage implementation into a dedicated module for improved code maintainability and organization. No user-facing changes.

✏️ Tip: You can customize this high-level summary in your review settings.

Move out `FilterHeadersStorage` and `PersistentFilterHeadersStorage` into `storage/filters.rs` to have one storage type per file.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

Refactors storage architecture by extracting filter header persistence logic into a dedicated module. Moves FilterHeaderStorage trait and PersistentFilterHeaderStorage implementation from filters.rs to a new filter_headers.rs file, updating module exports and imports to maintain API compatibility.

Changes

Cohort / File(s) Summary
Filter Headers Storage Module
dash-spv/src/storage/filter_headers.rs
New module introducing FilterHeaderStorage trait with async methods for storing, loading, and querying filter headers. Adds PersistentFilterHeaderStorage struct implementing both FilterHeaderStorage and PersistentStorage traits, using RwLock-guarded SegmentCache for concurrent access and persistent lifecycle management.
Filter Storage Cleanup
dash-spv/src/storage/filters.rs
Removes FilterHeaderStorage trait and PersistentFilterHeaderStorage struct that were previously defined here, consolidating filter header storage logic into the dedicated filter_headers module.
Module Exports
dash-spv/src/storage/mod.rs
Declares new filter_headers module, updates public export path for FilterHeaderStorage from filters to filter_headers, and adjusts internal imports to resolve PersistentFilterHeaderStorage and PersistentFilterStorage from their respective modules.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hopping files to better places,
Organizing storage spaces,
Filters now have their own home,
No more tangled code to roam!
Clean and cozy, all arranged,
Refactored without a change!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 pull request title 'refactor: one storage type per file' accurately describes the main objective of the changeset, which involves reorganizing storage types by moving FilterHeaderStorage and PersistentFilterHeaderStorage into a dedicated filter_headers.rs file to follow a one-type-per-file structure.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@dash-spv/src/storage/filter_headers.rs`:
- Around line 10-34: get_filter_header currently constructs a range with height
+ 1 which can overflow for u32::MAX; change it to use height.checked_add(1) and
return Ok(None) if it returns None. Specifically, in the get_filter_header
method (which calls get_filter_tip_height, get_filter_start_height, and
load_filter_headers), replace the direct height + 1 usage with a checked_add(1)
call and early-return Ok(None) on None to avoid panic/wrap-around before calling
load_filter_headers(height..end). Ensure you still call load_filter_headers with
the computed end only when checked_add succeeds.

@xdustinface xdustinface merged commit 9a25072 into v0.42-dev Jan 29, 2026
53 checks passed
@xdustinface xdustinface deleted the refactor/one-storage-per-file branch January 29, 2026 22:37
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.

3 participants