diff --git a/zebra-chain/src/parameters/network/subsidy.rs b/zebra-chain/src/parameters/network/subsidy.rs index d6672d30e80..8cd6029f48b 100644 --- a/zebra-chain/src/parameters/network/subsidy.rs +++ b/zebra-chain/src/parameters/network/subsidy.rs @@ -413,8 +413,7 @@ impl ParameterSubsidy for Network { } else if params.is_default_testnet() { FIRST_HALVING_TESTNET } else { - height_for_halving_index(1, self) - .expect("first halving height should be available") + height_for_halving(1, self).expect("first halving height should be available") } } } @@ -558,8 +557,8 @@ pub fn funding_stream_address_period(height: Height, networ /// See `Halving(height)`, as described in [protocol specification ยง7.8][7.8] /// /// [7.8]: https://zips.z.cash/protocol/protocol.pdf#subsidies -pub fn height_for_halving_index(halving_index: u32, network: &Network) -> Option { - if halving_index == 0 { +pub fn height_for_halving(halving: u32, network: &Network) -> Option { + if halving == 0 { return Some(Height(0)); } @@ -571,7 +570,7 @@ pub fn height_for_halving_index(halving_index: u32, network: &Network) -> Option .0, ); let pre_blossom_halving_interval = network.pre_blossom_halving_interval(); - let halving_index = i64::from(halving_index); + let halving_index = i64::from(halving); let unscaled_height = halving_index .checked_mul(pre_blossom_halving_interval) diff --git a/zebra-consensus/src/block/subsidy/general.rs b/zebra-consensus/src/block/subsidy/general.rs index 48a5fb0d36c..d871751da34 100644 --- a/zebra-consensus/src/block/subsidy/general.rs +++ b/zebra-consensus/src/block/subsidy/general.rs @@ -506,14 +506,11 @@ mod test { #[test] fn check_height_for_num_halvings() { for network in Network::iter() { - for halving_index in 1..1000 { + for halving in 1..1000 { let Some(height_for_halving) = - zebra_chain::parameters::subsidy::height_for_halving_index( - halving_index, - &network, - ) + zebra_chain::parameters::subsidy::height_for_halving(halving, &network) else { - panic!("could not find height for halving {halving_index}"); + panic!("could not find height for halving {halving}"); }; let prev_height = height_for_halving @@ -521,13 +518,13 @@ mod test { .expect("there should be a previous height"); assert_eq!( - halving_index, + halving, num_halvings(height_for_halving, &network), "num_halvings should match the halving index" ); assert_eq!( - halving_index - 1, + halving - 1, num_halvings(prev_height, &network), "num_halvings for the prev height should be 1 less than the halving index" );