orphan check needs to handle fast sync "edge case" (#3418)

This commit is contained in:
Antioch Peverell 2020-08-08 11:21:38 +01:00 committed by GitHub
parent 4732a0b62b
commit 34adaf797e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -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(());
}

View file

@ -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