diff --git a/crates/storage/db/src/abstraction/table.rs b/crates/storage/db/src/abstraction/table.rs index 691d12db27..cd3fffbd89 100644 --- a/crates/storage/db/src/abstraction/table.rs +++ b/crates/storage/db/src/abstraction/table.rs @@ -101,19 +101,20 @@ pub trait TableImporter<'tx>: for<'a> DbTxMut<'a> { source_tx: &R, from: Option<::Key>, to: ::Key, - ) -> Result<(), Error> { + ) -> Result<(), Error> + where + T::Key: Default, + { let mut destination_cursor = self.cursor_write::()?; let mut source_cursor = source_tx.cursor_read::()?; - 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(())