Skip to content

Commit

Permalink
refactor: Use Arc<Block> in BlockVerifier
Browse files Browse the repository at this point in the history
Arc is a bit more flexible when using futures.

And improve the documentation for coinbase_is_first_check.

Closes #627.
  • Loading branch information
teor2345 authored and hdevalence committed Jul 15, 2020
1 parent 30effa6 commit 6f064e0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions zebra-consensus/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@ pub(crate) fn node_time_check(
}
}

/// Check that there is exactly one coinbase transaction in `Block`, and that
/// the coinbase transaction is the first transaction in the block.
///
/// "The first (and only the first) transaction in a block is a coinbase
/// transaction, which collects and spends any miner subsidy and transaction
/// fees paid by transactions included in this block."[S 3.10][3.10]
///
/// [3.10]: https://zips.z.cash/protocol/protocol.pdf#coinbasetransactions
pub(crate) fn coinbase_check(block: &Block) -> Result<(), Error> {
pub(crate) fn coinbase_is_first_check(block: Arc<Block>) -> Result<(), Error> {
if block.coinbase_height().is_some() {
// No coinbase inputs in additional transactions allowed
if block
Expand Down Expand Up @@ -116,7 +123,7 @@ where
let now = Utc::now();
node_time_check(block.header.time, now)?;
block.header.is_equihash_solution_valid()?;
coinbase_check(block.as_ref())?;
coinbase_is_first_check(block.clone())?;

// `Tower::Buffer` requires a 1:1 relationship between `poll()`s
// and `call()`s, because it reserves a buffer slot in each
Expand Down

0 comments on commit 6f064e0

Please sign in to comment.