From 83ce56e8a8f7fe060a8f6cc6ec45866e67fe2711 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:23:18 -0400 Subject: [PATCH] feat: make unwind_table_by_walker take RangeBounds (#9404) --- crates/stages/stages/src/stages/headers.rs | 2 +- crates/storage/provider/src/providers/database/provider.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/stages/stages/src/stages/headers.rs b/crates/stages/stages/src/stages/headers.rs index 71c57cae40..1065869915 100644 --- a/crates/stages/stages/src/stages/headers.rs +++ b/crates/stages/stages/src/stages/headers.rs @@ -317,7 +317,7 @@ where // First unwind the db tables, until the unwind_to block number. use the walker to unwind // HeaderNumbers based on the index in CanonicalHeaders provider.unwind_table_by_walker::( - input.unwind_to, + input.unwind_to.., )?; provider.unwind_table_by_num::(input.unwind_to)?; provider.unwind_table_by_num::(input.unwind_to)?; diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index 970c77b399..9e8e3bf355 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -1078,13 +1078,16 @@ impl DatabaseProvider { } /// Unwind a table forward by a [`Walker`][reth_db_api::cursor::Walker] on another table - pub fn unwind_table_by_walker(&self, start_at: T1::Key) -> Result<(), DatabaseError> + pub fn unwind_table_by_walker( + &self, + range: impl RangeBounds, + ) -> Result<(), DatabaseError> where T1: Table, T2: Table, { let mut cursor = self.tx.cursor_write::()?; - let mut walker = cursor.walk(Some(start_at))?; + let mut walker = cursor.walk_range(range)?; while let Some((_, value)) = walker.next().transpose()? { self.tx.delete::(value, None)?; }