Remove InvalidParentHash in favor of assert! (#8300)

* Remove InvalidParentHash in favor of assert!

* Typo: assert test true case
This commit is contained in:
Wei Tang
2018-04-05 17:03:25 +08:00
committed by André Silva
parent 9d3771458d
commit e4168c2985
2 changed files with 3 additions and 7 deletions

View File

@@ -304,11 +304,11 @@ pub fn verify_header_params(header: &Header, engine: &EthEngine, is_full: bool)
/// Check header parameters agains parent header.
fn verify_parent(header: &Header, parent: &Header, engine: &EthEngine) -> Result<(), Error> {
assert!(header.parent_hash().is_zero() || &parent.hash() == header.parent_hash(),
"Parent hash should already have been verified; qed");
let gas_limit_divisor = engine.params().gas_limit_bound_divisor;
if !header.parent_hash().is_zero() && &parent.hash() != header.parent_hash() {
return Err(From::from(BlockError::InvalidParentHash(Mismatch { expected: parent.hash(), found: header.parent_hash().clone() })))
}
if !engine.is_timestamp_valid(header.timestamp(), parent.timestamp()) {
return Err(From::from(BlockError::InvalidTimestamp(OutOfBounds { max: None, min: Some(parent.timestamp() + 1), found: header.timestamp() })))
}