Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions crates/networking/p2p/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,21 +531,25 @@ impl Syncer {
) -> Result<(), (ChainError, Option<BatchBlockProcessingFailure>)> {
// If we found the sync head, run the blocks sequentially to store all the blocks's state
if sync_head_found {
let mut last_valid_hash = H256::default();
for block in blocks {
let block_hash = block.hash();
blockchain.add_block_pipeline(block).map_err(|e| {
(
e,
Some(BatchBlockProcessingFailure {
last_valid_hash,
failed_block_hash: block_hash,
}),
)
})?;
last_valid_hash = block_hash;
}
Ok(())
tokio::task::spawn_blocking(move || {
let mut last_valid_hash = H256::default();
for block in blocks {
let block_hash = block.hash();
blockchain.add_block_pipeline(block).map_err(|e| {
(
e,
Some(BatchBlockProcessingFailure {
last_valid_hash,
failed_block_hash: block_hash,
}),
)
})?;
last_valid_hash = block_hash;
}
Ok(())
})
.await
.map_err(|e| (ChainError::Custom(e.to_string()), None))?
} else {
blockchain.add_blocks_in_batch(blocks, cancel_token).await
}
Expand Down