mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
orphan check needs to handle fast sync "edge case" (#3418)
This commit is contained in:
parent
4732a0b62b
commit
34adaf797e
2 changed files with 6 additions and 3 deletions
|
@ -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(());
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue