diff --git a/chain/src/chain.rs b/chain/src/chain.rs index 79afebf0b..917decb3c 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -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(()); } diff --git a/chain/src/pipe.rs b/chain/src/pipe.rs index 9ac1214fa..f7ba97e6b 100644 --- a/chain/src/pipe.rs +++ b/chain/src/pipe.rs @@ -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