Repository navigation
chore: drop unused completed_count in BlocksPipeline - #477
Conversation
Cleanup dead code.
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 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
trueeven whenhash_to_heighthas no entry, which can silently hide internal state divergence (coordinator vs. height map). Consider emitting a warning/assert in that branch to preserve debuggability.Based on learnings: "Implement independent state management for each sync phase tracked with clear state transitions".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🤖 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.
Cleanup dead code.
Summary by CodeRabbit
Release Notes