readonly verify_coinbase_maturity (#2164)

* move verify_coinbase_maturity into utxo_view
no longer need a write lock on txhashset

* rustfmt
This commit is contained in:
Antioch Peverell
2018-12-16 09:26:39 +00:00
committed by GitHub
parent a50dcbfaa5
commit c188b60a38
4 changed files with 85 additions and 65 deletions
+5 -13
View File
@@ -434,16 +434,10 @@ fn validate_block(block: &Block, ctx: &mut BlockContext<'_>) -> Result<(), Error
Ok(())
}
/// TODO - This can move into the utxo_view.
/// Verify the block is not attempting to spend coinbase outputs
/// before they have sufficiently matured.
/// Note: requires a txhashset extension.
fn verify_coinbase_maturity(
block: &Block,
ext: &mut txhashset::Extension<'_>,
) -> Result<(), Error> {
ext.verify_coinbase_maturity(&block.inputs(), block.header.height)?;
Ok(())
/// Verify the block is not spending coinbase outputs before they have sufficiently matured.
fn verify_coinbase_maturity(block: &Block, ext: &txhashset::Extension<'_>) -> Result<(), Error> {
ext.utxo_view()
.verify_coinbase_maturity(&block.inputs(), block.header.height)
}
/// Some "real magick" verification logic.
@@ -649,7 +643,5 @@ pub fn rewind_and_apply_fork(b: &Block, ext: &mut txhashset::Extension<'_>) -> R
}
fn validate_utxo(block: &Block, ext: &txhashset::Extension<'_>) -> Result<(), Error> {
let utxo = ext.utxo_view();
utxo.validate_block(block)?;
Ok(())
ext.utxo_view().validate_block(block)
}