From b8e902d561e5c5564f00ac9b22b7ef21450fe0b4 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Tue, 16 Jan 2024 20:13:39 +0800 Subject: [PATCH] Change BLOCK_PARTIAL_STORED to BLOCK_STORED --- chain/src/consume_orphan.rs | 12 +++++------- sync/src/synchronizer/block_fetcher.rs | 4 ++-- sync/src/synchronizer/mod.rs | 8 ++++---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/chain/src/consume_orphan.rs b/chain/src/consume_orphan.rs index 6770bf60ce..6550e54616 100644 --- a/chain/src/consume_orphan.rs +++ b/chain/src/consume_orphan.rs @@ -148,10 +148,8 @@ impl ConsumeDescendantProcessor { pub(crate) fn process_descendant(&self, lonely_block: LonelyBlockWithCallback) { match self.accept_descendant(lonely_block.block().to_owned()) { Ok((parent_header, total_difficulty)) => { - self.shared.insert_block_status( - lonely_block.block().hash(), - BlockStatus::BLOCK_PARTIAL_STORED, - ); + self.shared + .insert_block_status(lonely_block.block().hash(), BlockStatus::BLOCK_STORED); let unverified_block: UnverifiedBlock = lonely_block.combine_parent_header(parent_header); @@ -266,9 +264,9 @@ impl ConsumeOrphan { if !self.shared.contains_block_status( self.shared.store(), &leader_hash, - BlockStatus::BLOCK_PARTIAL_STORED, + BlockStatus::BLOCK_STORED, ) { - trace!("orphan leader: {} not partial stored", leader_hash); + trace!("orphan leader: {} not stored", leader_hash); continue; } @@ -291,7 +289,7 @@ impl ConsumeOrphan { let parent_status = self .shared .get_block_status(self.shared.store(), &parent_hash); - if parent_status.contains(BlockStatus::BLOCK_PARTIAL_STORED) { + if parent_status.contains(BlockStatus::BLOCK_STORED) { debug!( "parent {} has stored: {:?}, processing descendant directly {}-{}", parent_hash, diff --git a/sync/src/synchronizer/block_fetcher.rs b/sync/src/synchronizer/block_fetcher.rs index 1a021f3983..c91a005c4d 100644 --- a/sync/src/synchronizer/block_fetcher.rs +++ b/sync/src/synchronizer/block_fetcher.rs @@ -210,8 +210,8 @@ impl BlockFetcher { let parent_hash = header.parent_hash(); let hash = header.hash(); - if status.contains(BlockStatus::BLOCK_PARTIAL_STORED) { - if status.contains(BlockStatus::BLOCK_STORED) { + if status.contains(BlockStatus::BLOCK_STORED) { + if status.contains(BlockStatus::BLOCK_VALID) { // If the block is stored, its ancestor must on store // So we can skip the search of this space directly self.sync_shared diff --git a/sync/src/synchronizer/mod.rs b/sync/src/synchronizer/mod.rs index 763c773820..d3ff3a9a4e 100644 --- a/sync/src/synchronizer/mod.rs +++ b/sync/src/synchronizer/mod.rs @@ -363,8 +363,8 @@ impl Synchronizer { let status = self.shared.active_chain().get_block_status(&block_hash); // NOTE: Filtering `BLOCK_STORED` but not `BLOCK_RECEIVED`, is for avoiding // stopping synchronization even when orphan_pool maintains dirty items by bugs. - if status.contains(BlockStatus::BLOCK_PARTIAL_STORED) { - error!("Block {} already partial stored", block_hash); + if status.contains(BlockStatus::BLOCK_STORED) { + error!("Block {} already stored", block_hash); } else if status.contains(BlockStatus::HEADER_VALID) { self.shared .insert_new_block(&self.chain, Arc::new(block), peer_id, message_bytes); @@ -388,8 +388,8 @@ impl Synchronizer { let status = self.shared.active_chain().get_block_status(&block_hash); // NOTE: Filtering `BLOCK_STORED` but not `BLOCK_RECEIVED`, is for avoiding // stopping synchronization even when orphan_pool maintains dirty items by bugs. - if status.contains(BlockStatus::BLOCK_PARTIAL_STORED) { - error!("block {} already partial stored", block_hash); + if status.contains(BlockStatus::BLOCK_STORED) { + error!("block {} already stored", block_hash); Ok(false) } else if status.contains(BlockStatus::HEADER_VALID) { self.shared.blocking_insert_new_block_with_verbose_info(