Skip to content

Commit d331a46

Browse files
committed
Move new root check outside
1 parent c75a523 commit d331a46

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

consensus/src/pipeline/pruning_processor/processor.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -565,24 +565,25 @@ impl PruningProcessor {
565565
while retention_period_root != new_retention_period_root {
566566
let block = new_retention_period_root;
567567

568-
// We may be at a block that's already in the past of current retention_period_root. Clamp to retention_period_root here.
569-
// Happens when the node is newly started and retention_period_root itself still doesn't cover the full retention period.
570-
if self.reachability_service.is_dag_ancestor_of(block, retention_period_root) {
571-
new_retention_period_root = retention_period_root;
572-
break;
573-
}
574-
575568
let timestamp = self.headers_store.get_compact_header_data(block).unwrap().timestamp;
576569
trace!("block | timestamp = {} | {}", block, timestamp);
577570
if timestamp < retention_period_root_ts_target {
578571
trace!("block {} timestamp {} >= {}", block, timestamp, retention_period_root_ts_target);
579-
// We are now at a pruning point that is at or above our retention period target
572+
// We are now at a pruning point that is at or below our retention period target
580573
break;
581574
}
582575

583576
new_retention_period_root = self.pruning_samples_store.pruning_sample_from_pov(block).unwrap_or(retention_period_root);
584577
}
585578

579+
// We may be at a pruning sample that's in the past or anticone of current retention_period_root. Clamp to retention_period_root here.
580+
// Happens when the node is newly started and retention_period_root itself still doesn't cover the full retention period.
581+
let is_new_root_in_future_of_old =
582+
self.reachability_service.is_dag_ancestor_of(retention_period_root, new_retention_period_root);
583+
if !is_new_root_in_future_of_old {
584+
new_retention_period_root = retention_period_root;
585+
}
586+
586587
new_retention_period_root
587588
}
588589

0 commit comments

Comments
 (0)