Skip to content

Commit

Permalink
Change BLOCK_PARTIAL_STORED to BLOCK_STORED
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Jan 16, 2024
1 parent 1eae3b1 commit b8e902d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
12 changes: 5 additions & 7 deletions chain/src/consume_orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions sync/src/synchronizer/block_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions sync/src/synchronizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand Down

0 comments on commit b8e902d

Please sign in to comment.