Skip to content

Commit

Permalink
reverts update to can_fork_chain_at()
Browse files Browse the repository at this point in the history
  • Loading branch information
arya2 committed Mar 23, 2023
1 parent 3331d7f commit 0152c86
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions zebra-state/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,25 +708,25 @@ impl StateService {
}

// Wait until block commit task is ready to write non-finalized blocks before dequeuing them
self.send_ready_non_finalized_queued(parent_hash);
if self.finalized_block_write_sender.is_none() {
self.send_ready_non_finalized_queued(parent_hash);

let finalized_tip_height = self.read_service.db.finalized_tip_height().expect(
"Finalized state must have at least one block before committing non-finalized state",
);
let finalized_tip_height = self.read_service.db.finalized_tip_height().expect(
"Finalized state must have at least one block before committing non-finalized state",
);

self.queued_non_finalized_blocks
.prune_by_height(finalized_tip_height);
self.queued_non_finalized_blocks
.prune_by_height(finalized_tip_height);

self.sent_blocks.prune_by_height(finalized_tip_height);
self.sent_blocks.prune_by_height(finalized_tip_height);
}

rsp_rx
}

/// Returns `true` if `hash` is a valid previous block hash for new non-finalized blocks.
fn can_fork_chain_at(&self, hash: &block::Hash) -> bool {
self.finalized_block_write_sender.is_none()
&& (self.sent_blocks.contains(hash)
|| &self.read_service.db.finalized_tip_hash() == hash)
self.sent_blocks.contains(hash) || &self.read_service.db.finalized_tip_hash() == hash
}

/// Returns `true` if `queued_height` is near the final checkpoint.
Expand Down

0 comments on commit 0152c86

Please sign in to comment.