Swap subsidy_is_valid argument order

This change makes the function consistent with the other check::*
functions.
This commit is contained in:
teor 2020-10-13 07:41:24 +10:00
parent 3fad3cf3af
commit 4e952a3930
3 changed files with 5 additions and 6 deletions

View File

@ -151,7 +151,7 @@ where
check::time_is_valid_at(&block.header, now, &height, &hash)
.map_err(VerifyBlockError::Time)?;
check::coinbase_is_first(&block)?;
check::subsidy_is_valid(network, &block)?;
check::subsidy_is_valid(&block, network)?;
// TODO: context-free header verification: merkle root

View File

@ -100,7 +100,7 @@ pub fn time_is_valid_at(
/// Returns `Ok(())` if the block subsidy and miner fees in `block` are valid for `network`
///
/// [3.9]: https://zips.z.cash/protocol/protocol.pdf#subsidyconcepts
pub fn subsidy_is_valid(network: Network, block: &Block) -> Result<(), BlockError> {
pub fn subsidy_is_valid(block: &Block, network: Network) -> Result<(), BlockError> {
let height = block.coinbase_height().ok_or(SubsidyError::NoCoinbase)?;
let coinbase = block.transactions.get(0).ok_or(SubsidyError::NoCoinbase)?;

View File

@ -175,8 +175,7 @@ fn subsidy_is_valid_for_network(network: Network) -> Result<(), Report> {
if block::Height(height) > SLOW_START_INTERVAL
&& block::Height(height) < NetworkUpgrade::Canopy.activation_height(network).unwrap()
{
check::subsidy_is_valid(network, &block)
.expect("subsidies should pass for this block");
check::subsidy_is_valid(&block, network).expect("subsidies should pass for this block");
}
}
Ok(())
@ -198,7 +197,7 @@ fn nocoinbase_validation_failure() -> Result<(), Report> {
block.transactions.remove(0);
// Validate the block
let result = check::subsidy_is_valid(network, &block).unwrap_err();
let result = check::subsidy_is_valid(&block, network).unwrap_err();
let expected = BlockError::Transaction(TransactionError::Subsidy(SubsidyError::NoCoinbase));
assert_eq!(expected, result);
@ -244,7 +243,7 @@ fn founders_reward_validation_failure() -> Result<(), Report> {
};
// Validate it
let result = check::subsidy_is_valid(network, &block).unwrap_err();
let result = check::subsidy_is_valid(&block, network).unwrap_err();
let expected = BlockError::Transaction(TransactionError::Subsidy(
SubsidyError::FoundersRewardNotFound,
));