mirror of https://github.com/zcash/zips.git
Fix AddressPeriod(height) to align with halving heights
This commit is contained in:
parent
2f0817d567
commit
3322acf19e
10
zip-0207.rst
10
zip-0207.rst
|
@ -86,14 +86,14 @@ block height is defined as follows::
|
|||
AddressChangeInterval = PostBlossomHalvingInterval / 48
|
||||
AddressPeriod(height) =
|
||||
floor((
|
||||
height + AddressChangeInterval - SlowStartShift
|
||||
height + PostBlossomHalvingInterval - HeightForHalving(1)
|
||||
) / AddressChangeInterval)
|
||||
FundingStream[FUND].AddressIndex(height) =
|
||||
AddressPeriod(height) - AddressPeriod(FundingStream[FUND].StartHeight)
|
||||
Address(height) = FundingStream[FUND].Addresses[FundingStream[FUND].AddressIndex(height)]
|
||||
|
||||
This has the property that all active funding streams change the address they are using on the same block
|
||||
height schedule, aligned to the end of the mining slow start so that 48 funding periods fit cleanly within a
|
||||
height schedule, aligned to the height of the first halving so that 48 funding periods fit cleanly within a
|
||||
halving interval. This can be leveraged to simplify implementations, by batching the necessary outputs for
|
||||
each funding period.
|
||||
|
||||
|
@ -241,10 +241,12 @@ Example implementation
|
|||
{
|
||||
// Integer division is floor division in C++
|
||||
auto curPeriod = (
|
||||
nHeight + params.nFundingPeriodLength - params.SubsidySlowStartShift()
|
||||
nHeight + params.nSubsidyPostBlossomHalvingInterval - HeightForHalving(params, 1)
|
||||
) / params.nFundingPeriodLength;
|
||||
auto startPeriod = (
|
||||
params.vFundingPeriods[idx].startHeight + params.nFundingPeriodLength - params.SubsidySlowStartShift()
|
||||
params.vFundingPeriods[idx].startHeight
|
||||
+ params.nSubsidyPostBlossomHalvingInterval
|
||||
- HeightForHalving(params, 1)
|
||||
) / params.nFundingPeriodLength;
|
||||
auto addressIndex = curPeriod - startPeriod;
|
||||
return params.vFundingPeriods[idx].addresses[addressIndex];
|
||||
|
|
Loading…
Reference in New Issue