From 45d801ba1c75e4af9c68d425912fc9c61d308a62 Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Tue, 22 Aug 2023 11:08:54 +0100 Subject: [PATCH] check tip block number --- crates/prune/src/pruner.rs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/crates/prune/src/pruner.rs b/crates/prune/src/pruner.rs index 2a88df63d656c..796d5d563abbc 100644 --- a/crates/prune/src/pruner.rs +++ b/crates/prune/src/pruner.rs @@ -94,11 +94,12 @@ impl Pruner { /// Run the pruner pub fn run(&mut self, tip_block_number: BlockNumber) -> PrunerResult { - trace!( - target: "pruner", - %tip_block_number, - "Pruner started" - ); + if tip_block_number == 0 { + trace!(target: "pruner", %tip_block_number, "Nothing to prune yet"); + return Ok(true) + } + + trace!(target: "pruner", %tip_block_number, "Pruner started"); let start = Instant::now(); let provider = self.provider_factory.provider_rw()?; @@ -124,11 +125,7 @@ impl Pruner { .duration_seconds .record(part_start.elapsed()) } else { - trace!( - target: "pruner", - prune_part = ?PrunePart::Receipts, - "No target block to prune" - ); + trace!(target: "pruner", prune_part = ?PrunePart::Receipts, "No target block to prune"); } if !self.modes.contract_logs_filter.is_empty() { @@ -250,12 +247,7 @@ impl Pruner { let elapsed = start.elapsed(); self.metrics.duration_seconds.record(elapsed); - trace!( - target: "pruner", - %tip_block_number, - ?elapsed, - "Pruner finished" - ); + trace!(target: "pruner", %tip_block_number, ?elapsed, "Pruner finished"); Ok(done) }