fixed overflow subtraction

This commit is contained in:
Jędrzej Stuczyński
2024-05-07 11:47:59 +01:00
parent f827eb4242
commit 0af807ac92
@@ -245,13 +245,18 @@ impl BlockProcessor {
.try_into()
.unwrap_or_default();
let to_prune = last_to_keep - lowest;
let to_prune = last_to_keep.saturating_sub(lowest);
match to_prune {
v if v > 1000 => warn!("approximately {v} blocks worth of data will be pruned"),
v if v > 100 => info!("approximately {v} blocks worth of data will be pruned"),
v if v == 0 => trace!("no blocks to prune"),
v => debug!("approximately {v} blocks worth of data will be pruned"),
}
if to_prune == 0 {
return Ok(());
}
self.storage
.prune_storage(last_to_keep, self.last_processed_height)
.await?;