From c537d427b81c94b43201ff3d704e799c3b607599 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 22 Nov 2024 05:25:54 +0400 Subject: [PATCH] fix: always truncate static files --- .../provider/src/providers/database/provider.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index d35e0a971a37..ff80213fdf31 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -3030,13 +3030,13 @@ impl BlockWriter .static_file_provider .get_highest_static_file_tx(StaticFileSegment::Transactions); - if let Some(static_tx) = static_file_tx_num { - if static_tx >= unwind_tx_from { - self.static_file_provider - .latest_writer(StaticFileSegment::Transactions)? - .prune_transactions(static_tx - unwind_tx_from + 1, block)?; - } - } + let to_delete = static_file_tx_num + .map(|static_tx| (static_tx + 1).saturating_sub(unwind_tx_from)) + .unwrap_or_default(); + + self.static_file_provider + .latest_writer(StaticFileSegment::Transactions)? + .prune_transactions(to_delete, block)?; } Ok(())