Swap subsidy_is_valid argument order
This change makes the function consistent with the other check::* functions.
This commit is contained in:
parent
3fad3cf3af
commit
4e952a3930
|
@ -151,7 +151,7 @@ where
|
||||||
check::time_is_valid_at(&block.header, now, &height, &hash)
|
check::time_is_valid_at(&block.header, now, &height, &hash)
|
||||||
.map_err(VerifyBlockError::Time)?;
|
.map_err(VerifyBlockError::Time)?;
|
||||||
check::coinbase_is_first(&block)?;
|
check::coinbase_is_first(&block)?;
|
||||||
check::subsidy_is_valid(network, &block)?;
|
check::subsidy_is_valid(&block, network)?;
|
||||||
|
|
||||||
// TODO: context-free header verification: merkle root
|
// TODO: context-free header verification: merkle root
|
||||||
|
|
||||||
|
|
|
@ -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`
|
/// 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
|
/// [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 height = block.coinbase_height().ok_or(SubsidyError::NoCoinbase)?;
|
||||||
let coinbase = block.transactions.get(0).ok_or(SubsidyError::NoCoinbase)?;
|
let coinbase = block.transactions.get(0).ok_or(SubsidyError::NoCoinbase)?;
|
||||||
|
|
||||||
|
|
|
@ -175,8 +175,7 @@ fn subsidy_is_valid_for_network(network: Network) -> Result<(), Report> {
|
||||||
if block::Height(height) > SLOW_START_INTERVAL
|
if block::Height(height) > SLOW_START_INTERVAL
|
||||||
&& block::Height(height) < NetworkUpgrade::Canopy.activation_height(network).unwrap()
|
&& block::Height(height) < NetworkUpgrade::Canopy.activation_height(network).unwrap()
|
||||||
{
|
{
|
||||||
check::subsidy_is_valid(network, &block)
|
check::subsidy_is_valid(&block, network).expect("subsidies should pass for this block");
|
||||||
.expect("subsidies should pass for this block");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -198,7 +197,7 @@ fn nocoinbase_validation_failure() -> Result<(), Report> {
|
||||||
block.transactions.remove(0);
|
block.transactions.remove(0);
|
||||||
|
|
||||||
// Validate the block
|
// 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));
|
let expected = BlockError::Transaction(TransactionError::Subsidy(SubsidyError::NoCoinbase));
|
||||||
assert_eq!(expected, result);
|
assert_eq!(expected, result);
|
||||||
|
|
||||||
|
@ -244,7 +243,7 @@ fn founders_reward_validation_failure() -> Result<(), Report> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Validate it
|
// 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(
|
let expected = BlockError::Transaction(TransactionError::Subsidy(
|
||||||
SubsidyError::FoundersRewardNotFound,
|
SubsidyError::FoundersRewardNotFound,
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in New Issue