Skip to content

Commit

Permalink
fix: importer-offline checking for shutdown after each block (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhani-cw authored May 23, 2024
1 parent 2fe0093 commit 7c54397
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/bin/importer_offline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,27 +148,26 @@ async fn execute_block_importer(

tracing::info!(%block_start, %block_end, receipts = %receipts.len(), "importing blocks");
for (block_index, block) in blocks.into_iter().enumerate() {
async {
// re-execute block
executor.reexecute_external(&block, &receipts).await?;
if GlobalState::warn_if_shutdown(TASK_NAME) {
return Ok(());
}

// mine block
let mined_block = miner.mine_external().await?;
// re-execute block
executor.reexecute_external(&block, &receipts).await?;

// export to csv OR permanent storage
match csv {
Some(ref mut csv) => import_external_to_csv(&storage, csv, mined_block.clone(), block_index, block_last_index).await?,
None => miner.commit(mined_block.clone()).await?,
};
// mine block
let mined_block = miner.mine_external().await?;

// export snapshot for tests
if blocks_to_export_snapshot.contains(mined_block.number()) {
export_snapshot(&block, &receipts, &mined_block)?;
}
// export to csv OR permanent storage
match csv {
Some(ref mut csv) => import_external_to_csv(&storage, csv, mined_block.clone(), block_index, block_last_index).await?,
None => miner.commit(mined_block.clone()).await?,
};

anyhow::Ok(())
// export snapshot for tests
if blocks_to_export_snapshot.contains(mined_block.number()) {
export_snapshot(&block, &receipts, &mined_block)?;
}
.await?;
}
}
}
Expand Down

0 comments on commit 7c54397

Please sign in to comment.