From fc6d7485dfaf446075767fdb38bca145e4d91f57 Mon Sep 17 00:00:00 2001 From: joshieDo Date: Tue, 27 Feb 2024 14:25:57 +0000 Subject: [PATCH] only start the pruner one the tip block has crossed the min block interval --- crates/prune/src/pruner.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/prune/src/pruner.rs b/crates/prune/src/pruner.rs index df7104b650e90..bb96a09b879d8 100644 --- a/crates/prune/src/pruner.rs +++ b/crates/prune/src/pruner.rs @@ -244,7 +244,9 @@ impl Pruner { /// Returns `true` if the pruning is needed at the provided tip block number. /// This determined by the check against minimum pruning interval and last pruned block number. pub fn is_pruning_needed(&self, tip_block_number: BlockNumber) -> bool { - if self.previous_tip_block_number.map_or(true, |previous_tip_block_number| { + if tip_block_number > self.min_block_interval as u64 { + false + } else if self.previous_tip_block_number.map_or(true, |previous_tip_block_number| { // Saturating subtraction is needed for the case when the chain was reverted, meaning // current block number might be less than the previous tip block number. // If that's the case, no pruning is needed as outdated data is also reverted.