mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-28 08:37:59 -05:00
feat: make unwind_table_by_walker take RangeBounds (#9404)
This commit is contained in:
@@ -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::<tables::CanonicalHeaders, tables::HeaderNumbers>(
|
||||
input.unwind_to,
|
||||
input.unwind_to..,
|
||||
)?;
|
||||
provider.unwind_table_by_num::<tables::CanonicalHeaders>(input.unwind_to)?;
|
||||
provider.unwind_table_by_num::<tables::HeaderTerminalDifficulties>(input.unwind_to)?;
|
||||
|
||||
@@ -1078,13 +1078,16 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
|
||||
}
|
||||
|
||||
/// Unwind a table forward by a [`Walker`][reth_db_api::cursor::Walker] on another table
|
||||
pub fn unwind_table_by_walker<T1, T2>(&self, start_at: T1::Key) -> Result<(), DatabaseError>
|
||||
pub fn unwind_table_by_walker<T1, T2>(
|
||||
&self,
|
||||
range: impl RangeBounds<T1::Key>,
|
||||
) -> Result<(), DatabaseError>
|
||||
where
|
||||
T1: Table,
|
||||
T2: Table<Key = T1::Value>,
|
||||
{
|
||||
let mut cursor = self.tx.cursor_write::<T1>()?;
|
||||
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::<T2>(value, None)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user