Skip to content

Commit

Permalink
tweak: snapshot importer extend by chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
zeapoz committed Apr 18, 2024
1 parent a17e5a5 commit c3c241c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/processor/tree/tree_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ impl TreeWrapper {
chunks: Vec<SnapshotStorageLogsChunk>,
l1_batch_number: U64,
) -> Result<()> {
let mut tree_entries = Vec::new();

let mut total_tree_entries = 0;
for (i, chunk) in chunks.iter().enumerate() {
let mut tree_entries = Vec::new();

tracing::info!("Importing chunk {}/{}...", i + 1, chunks.len());

for log in &chunk.storage_logs {
Expand All @@ -140,14 +141,15 @@ impl TreeWrapper {
.expect("cannot add key");
}

total_tree_entries += tree_entries.len();
self.tree.extend(tree_entries);

tracing::info!("Chunk {} was succesfully imported!", i + 1);
}

tracing::info!("Extending merkle tree with imported storage logs...");
let num_tree_entries = tree_entries.len();
self.tree.extend(tree_entries);

tracing::info!("Succesfully imported snapshot containing {num_tree_entries} storage logs!",);
tracing::info!(
"Succesfully imported snapshot containing {total_tree_entries} storage logs!",
);

let db = self.inner_db.lock().await;
db.set_latest_l1_batch_number(l1_batch_number.as_u64() + 1)?;
Expand Down

0 comments on commit c3c241c

Please sign in to comment.