Skip to content

Commit

Permalink
Fix orphan block pow verification.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdwldnqi837 committed Dec 2, 2019
1 parent 1a33222 commit e3383cd
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions chain/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,22 @@ fn check_known(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), E
// Validate only the proof of work in a block header.
// Used to cheaply validate orphans in process_block before adding them to OrphanBlockPool.
fn validate_pow_only(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), Error> {
if !header.pow.is_primary() && !header.pow.is_secondary() {
return Err(ErrorKind::LowEdgebits.into());
}
let edge_bits = header.pow.edge_bits();
if !(ctx.pow_verifier)(header).is_ok() {
error!(
"pipe: error validating header with cuckoo edge_bits {}",
edge_bits
);
return Err(ErrorKind::InvalidPow.into());
if header.height >= global::refactor_header_height() {
validate_block_auxdata(header, ctx)?;
} else {
if !header.pow.is_primary() && !header.pow.is_secondary() {
return Err(ErrorKind::LowEdgebits.into());
}
let edge_bits = header.pow.edge_bits();
if !(ctx.pow_verifier)(header).is_ok() {
error!(
"pipe: error validating header with cuckoo edge_bits {}",
edge_bits
);
return Err(ErrorKind::InvalidPow.into());
}
}

Ok(())
}

Expand Down

0 comments on commit e3383cd

Please sign in to comment.