consensus: check Merkle root immediately after difficulty
This commit is contained in:
parent
4fa119dd1f
commit
4fd9203785
|
@ -151,15 +151,8 @@ where
|
||||||
check::difficulty_is_valid(&block.header, network, &height, &hash)?;
|
check::difficulty_is_valid(&block.header, network, &height, &hash)?;
|
||||||
check::equihash_solution_is_valid(&block.header)?;
|
check::equihash_solution_is_valid(&block.header)?;
|
||||||
|
|
||||||
// Since errors cause an early exit, try to do the
|
// Next, check the Merkle root validity, to ensure that
|
||||||
// quick checks first.
|
// the header binds to the transactions in the blocks.
|
||||||
|
|
||||||
// Field validity and structure checks
|
|
||||||
let now = Utc::now();
|
|
||||||
check::time_is_valid_at(&block.header, now, &height, &hash)
|
|
||||||
.map_err(VerifyBlockError::Time)?;
|
|
||||||
check::coinbase_is_first(&block)?;
|
|
||||||
check::subsidy_is_valid(&block, network)?;
|
|
||||||
|
|
||||||
// Precomputing this avoids duplicating transaction hash computations.
|
// Precomputing this avoids duplicating transaction hash computations.
|
||||||
let transaction_hashes = block
|
let transaction_hashes = block
|
||||||
|
@ -170,6 +163,16 @@ where
|
||||||
|
|
||||||
check::merkle_root_validity(&block, &transaction_hashes)?;
|
check::merkle_root_validity(&block, &transaction_hashes)?;
|
||||||
|
|
||||||
|
// Since errors cause an early exit, try to do the
|
||||||
|
// quick checks first.
|
||||||
|
|
||||||
|
// Field validity and structure checks
|
||||||
|
let now = Utc::now();
|
||||||
|
check::time_is_valid_at(&block.header, now, &height, &hash)
|
||||||
|
.map_err(VerifyBlockError::Time)?;
|
||||||
|
check::coinbase_is_first(&block)?;
|
||||||
|
check::subsidy_is_valid(&block, network)?;
|
||||||
|
|
||||||
let mut async_checks = FuturesUnordered::new();
|
let mut async_checks = FuturesUnordered::new();
|
||||||
|
|
||||||
let known_utxos = new_outputs(&block, &transaction_hashes);
|
let known_utxos = new_outputs(&block, &transaction_hashes);
|
||||||
|
|
Loading…
Reference in New Issue