diff --git a/src/bin/importer_offline.rs b/src/bin/importer_offline.rs index cd10205a3..8d2baa1d1 100644 --- a/src/bin/importer_offline.rs +++ b/src/bin/importer_offline.rs @@ -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?; } } }