Fix: genesis pruning in engine (#289)

* Do not prune genesis

* Fix retain condition
This commit is contained in:
Daniel Sanchez 2023-08-03 12:25:33 +02:00 committed by GitHub
parent 083d061e46
commit fa8e1025f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -400,7 +400,10 @@ impl<O: Overlay> Carnot<O> {
/// Blocks newer than the last committed block are not safe to be pruned /// Blocks newer than the last committed block are not safe to be pruned
pub fn prune_older_blocks_by_view(&mut self, threshold_view: View) { pub fn prune_older_blocks_by_view(&mut self, threshold_view: View) {
assert!(threshold_view < self.latest_committed_block().view); assert!(threshold_view < self.latest_committed_block().view);
self.safe_blocks.retain(|_, b| b.view < threshold_view); // do not remove genesis
let view_zero = View::new(0);
self.safe_blocks
.retain(|_, b| b.view > threshold_view && view_zero == b.view);
} }
} }