Skip to content

Commit

Permalink
if no fork, execute at once
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzhhuang committed Sep 25, 2024
1 parent b7d157d commit 2d3745e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sync/src/tasks/block_sync_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,15 @@ where
Ok(())
}

async fn find_absent_ancestor(&self, mut block_headers: Vec<BlockHeader>) -> Result<()> {
async fn find_absent_ancestor(&self, mut block_headers: Vec<BlockHeader>) -> Result<u64> {
let mut count: u64 = 0;
loop {
let mut absent_blocks = vec![];
self.find_absent_parent_dag_blocks_for_blocks(block_headers, &mut absent_blocks)?;
if absent_blocks.is_empty() {
return Ok(());
return Ok(count);
}
count = count.saturating_add(absent_blocks.len() as u64);
block_headers = self.fetch_blocks(absent_blocks).await?;
}
}
Expand All @@ -449,10 +451,12 @@ where
block_header.parents_hash()
);
let fut = async {
self.find_absent_ancestor(vec![block_header.clone()])
let count = self
.find_absent_ancestor(vec![block_header.clone()])
.await?;

if block_header.number() % 1000 == 0
if count == 0
|| block_header.number() % 1000 == 0
|| block_header.number() >= self.target.target_id.number()
{
let parallel_execute = DagBlockSender::new(
Expand Down

0 comments on commit 2d3745e

Please sign in to comment.