Skip to content

chore: drop unused completed_count in BlocksPipeline - #477

Merged
xdustinface merged 1 commit into
v0.42-devfrom
chore/drop-completed-count
Feb 26, 2026
Merged

xdustinface merged 1 commit into
v0.42-devfrom
chore/drop-completed-count

Conversation

@xdustinface

@xdustinface xdustinface commented Feb 26, 2026 •

Copy link
Copy Markdown
Collaborator

Cleanup dead code.

Summary by CodeRabbit

Release Notes

  • Refactor
    • Streamlined the block synchronization pipeline by removing unused internal tracking mechanisms. Block reception logic now follows a simplified execution path with consistent handling across all block types.

@coderabbitai

coderabbitai Bot commented Feb 26, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The BlocksPipeline struct in dash-spv is simplified by removing the completed_count field that previously tracked completed block downloads. The receive_block method logic is also streamlined to always return true, eliminating conditional branching based on completion tracking.

Changes

Cohort / File(s) Summary
BlocksPipeline Refactoring
dash-spv/src/sync/blocks/pipeline.rs
Removed completed_count field from struct and its associated tracking logic in receive_block. Simplified return behavior to always return true. Removed field from Debug formatting and struct initialization.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A field we no longer need,
Completed counts fade like winter's seed,
The pipeline flows with simpler grace,
No counters cluttering up the place!
Cleaner logic, lighter still—
Hop along the refactored hill! 🌿

🚥 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 accurately summarizes the main change: removing the unused completed_count field from BlocksPipeline, which is the primary objective of this cleanup pull request.
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 chore/drop-completed-count

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
dash-spv/src/sync/blocks/pipeline.rs (1)

141-145: Add an explicit mismatch signal when a tracked hash has no height mapping.

At Line 145, the method returns true even when hash_to_height has no entry, which can silently hide internal state divergence (coordinator vs. height map). Consider emitting a warning/assert in that branch to preserve debuggability.

Proposed adjustment
-        if let Some(height) = self.hash_to_height.remove(&hash) {
+        if let Some(height) = self.hash_to_height.remove(&hash) {
             self.pending_heights.remove(&height);
             self.downloaded.insert(height, block.clone());
+        } else {
+            tracing::warn!(
+                "Received tracked block {} but no height mapping was found",
+                hash
+            );
+            debug_assert!(
+                false,
+                "BlocksPipeline state mismatch: coordinator accepted block without hash_to_height entry"
+            );
         }
         true
Based on learnings: "Implement independent state management for each sync phase tracked with clear state transitions".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dash-spv/src/sync/blocks/pipeline.rs` around lines 141 - 145, The method
currently removes a height and updates pending_heights/downloaded when
self.hash_to_height.remove(&hash) returns Some(...), but always returns true
even if no mapping existed; change the branch so that when
self.hash_to_height.remove(&hash) is None you signal a mismatch (e.g.,
processLogger.warn or debug_assert!, or return false) to surface coordinator vs
height-map divergence—update the logic around the hash handling in the function
that touches self.hash_to_height, self.pending_heights and self.downloaded to
emit that warning/assert or return a failure flag instead of silently returning
true.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@dash-spv/src/sync/blocks/pipeline.rs`:
- Around line 141-145: The method currently removes a height and updates
pending_heights/downloaded when self.hash_to_height.remove(&hash) returns
Some(...), but always returns true even if no mapping existed; change the branch
so that when self.hash_to_height.remove(&hash) is None you signal a mismatch
(e.g., processLogger.warn or debug_assert!, or return false) to surface
coordinator vs height-map divergence—update the logic around the hash handling
in the function that touches self.hash_to_height, self.pending_heights and
self.downloaded to emit that warning/assert or return a failure flag instead of
silently returning true.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c41375 and 735088c.

📒 Files selected for processing (1)
  • dash-spv/src/sync/blocks/pipeline.rs

@xdustinface
xdustinface requested a review from ZocoLini February 26, 2026 01:43
@xdustinface
xdustinface merged commit e678ae2 into v0.42-dev Feb 26, 2026
52 checks passed
@xdustinface
xdustinface deleted the chore/drop-completed-count branch February 26, 2026 15:56
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.

2 participants