Skip to content

Commit

Permalink
orphan check needs to handle fast sync "edge case" (#3418)
Browse files Browse the repository at this point in the history
  • Loading branch information
antiochp authored Aug 8, 2020
1 parent 4732a0b commit 34adaf7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,12 @@ impl Chain {

// Check if the provided block is an orphan.
// If block is an orphan add it to our orphan block pool for deferred processing.
// If this is the "next" block immediately following current head then not an orphan.
// Or if we have the previous full block then not an orphan.
fn check_orphan(&self, block: &Block, opts: Options) -> Result<(), Error> {
if self.block_exists(block.header.prev_hash)? {
let head = self.head()?;
let is_next = block.header.prev_hash == head.last_block_h;
if is_next || self.block_exists(block.header.prev_hash)? {
return Ok(());
}

Expand Down
3 changes: 1 addition & 2 deletions chain/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ pub fn process_block(
// want to do this now and not later during header validation.
validate_pow_only(&b.header, ctx)?;

// Get previous header from the db and check we have the corresponding full block.
// Get previous header from the db.
let prev = prev_header_store(&b.header, &mut ctx.batch)?;
ctx.batch.block_exists(&prev.hash())?;

// Process the header for the block.
// Note: We still want to process the full block if we have seen this header before
Expand Down

0 comments on commit 34adaf7

Please sign in to comment.