Skip to content

Commit

Permalink
only start the pruner once the tip block has crossed the min block in…
Browse files Browse the repository at this point in the history
…terval
  • Loading branch information
joshieDo committed Feb 27, 2024
1 parent ea4a4c7 commit 7249fff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/prune/src/pruner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ impl<DB: Database> Pruner<DB> {
/// 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.
Expand Down

0 comments on commit 7249fff

Please sign in to comment.