Skip to content

Commit

Permalink
Find the absent when starting the execution (#4248)
Browse files Browse the repository at this point in the history
* find the absent when starting the execution
  • Loading branch information
jackzhhuang authored Oct 24, 2024
1 parent 7cd0bd7 commit e97b2c5
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions sync/src/tasks/block_sync_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,15 +423,13 @@ where
Ok(())
}

async fn find_absent_ancestor(&self, mut block_headers: Vec<BlockHeader>) -> Result<u64> {
let mut count: u64 = 0;
async fn find_absent_ancestor(&self, mut block_headers: Vec<BlockHeader>) -> Result<()> {
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(count);
return Ok(());
}
count = count.saturating_add(absent_blocks.len() as u64);
block_headers = self.fetch_blocks(absent_blocks).await?;
}
}
Expand All @@ -453,17 +451,12 @@ where
block_header.parents_hash()
);
let fut = async {
let count = self
.find_absent_ancestor(vec![block_header.clone()])
.await?;

if count == 0 {
return anyhow::Ok(ParallelSign::Continue);
}

if block_header.number() % ASYNC_BLOCK_COUNT == 0
|| block_header.number() >= self.target.target_id.number()
{
self.find_absent_ancestor(vec![block_header.clone()])
.await?;

let parallel_execute = DagBlockSender::new(
self.sync_dag_store.clone(),
100000,
Expand Down

0 comments on commit e97b2c5

Please sign in to comment.