mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 17:18:08 -05:00
fix: use walk_range on import_table_with_range (#1364)
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com> Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
@@ -101,19 +101,20 @@ pub trait TableImporter<'tx>: for<'a> DbTxMut<'a> {
|
||||
source_tx: &R,
|
||||
from: Option<<T as Table>::Key>,
|
||||
to: <T as Table>::Key,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error>
|
||||
where
|
||||
T::Key: Default,
|
||||
{
|
||||
let mut destination_cursor = self.cursor_write::<T>()?;
|
||||
let mut source_cursor = source_tx.cursor_read::<T>()?;
|
||||
|
||||
for row in source_cursor.walk(from)? {
|
||||
let source_range = match from {
|
||||
Some(from) => source_cursor.walk_range(from..=to),
|
||||
None => source_cursor.walk_range(..=to),
|
||||
};
|
||||
for row in source_range? {
|
||||
let (key, value) = row?;
|
||||
let finished = key == to;
|
||||
|
||||
destination_cursor.append(key, value)?;
|
||||
|
||||
if finished {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user