feat: make unwind_table_by_walker take RangeBounds (#9404)

This commit is contained in:
Dan Cline
2024-07-09 15:23:18 -04:00
committed by GitHub
parent 63c8a82873
commit 83ce56e8a8
2 changed files with 6 additions and 3 deletions

View File

@ -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)?;
}