From e97b2c50f48b4523a42f9b0cca4949907e977fb7 Mon Sep 17 00:00:00 2001 From: Jack Huang Date: Fri, 25 Oct 2024 00:02:38 +0800 Subject: [PATCH] Find the absent when starting the execution (#4248) * find the absent when starting the execution --- sync/src/tasks/block_sync_task.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/sync/src/tasks/block_sync_task.rs b/sync/src/tasks/block_sync_task.rs index b218b70d2f..1f83b1b344 100644 --- a/sync/src/tasks/block_sync_task.rs +++ b/sync/src/tasks/block_sync_task.rs @@ -423,15 +423,13 @@ where Ok(()) } - async fn find_absent_ancestor(&self, mut block_headers: Vec) -> Result { - let mut count: u64 = 0; + async fn find_absent_ancestor(&self, mut block_headers: Vec) -> 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?; } } @@ -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,