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
|
AddressChangeInterval = PostBlossomHalvingInterval / 48
|
||||||
AddressPeriod(height) =
|
AddressPeriod(height) =
|
||||||
floor((
|
floor((
|
||||||
height + AddressChangeInterval - SlowStartShift
|
height + PostBlossomHalvingInterval - HeightForHalving(1)
|
||||||
) / AddressChangeInterval)
|
) / AddressChangeInterval)
|
||||||
FundingStream[FUND].AddressIndex(height) =
|
FundingStream[FUND].AddressIndex(height) =
|
||||||
AddressPeriod(height) - AddressPeriod(FundingStream[FUND].StartHeight)
|
AddressPeriod(height) - AddressPeriod(FundingStream[FUND].StartHeight)
|
||||||
Address(height) = FundingStream[FUND].Addresses[FundingStream[FUND].AddressIndex(height)]
|
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
|
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
|
halving interval. This can be leveraged to simplify implementations, by batching the necessary outputs for
|
||||||
each funding period.
|
each funding period.
|
||||||
|
|
||||||
|
@ -241,10 +241,12 @@ Example implementation
|
||||||
{
|
{
|
||||||
// Integer division is floor division in C++
|
// Integer division is floor division in C++
|
||||||
auto curPeriod = (
|
auto curPeriod = (
|
||||||
nHeight + params.nFundingPeriodLength - params.SubsidySlowStartShift()
|
nHeight + params.nSubsidyPostBlossomHalvingInterval - HeightForHalving(params, 1)
|
||||||
) / params.nFundingPeriodLength;
|
) / params.nFundingPeriodLength;
|
||||||
auto startPeriod = (
|
auto startPeriod = (
|
||||||
params.vFundingPeriods[idx].startHeight + params.nFundingPeriodLength - params.SubsidySlowStartShift()
|
params.vFundingPeriods[idx].startHeight
|
||||||
|
+ params.nSubsidyPostBlossomHalvingInterval
|
||||||
|
- HeightForHalving(params, 1)
|
||||||
) / params.nFundingPeriodLength;
|
) / params.nFundingPeriodLength;
|
||||||
auto addressIndex = curPeriod - startPeriod;
|
auto addressIndex = curPeriod - startPeriod;
|
||||||
return params.vFundingPeriods[idx].addresses[addressIndex];
|
return params.vFundingPeriods[idx].addresses[addressIndex];
|
||||||
|
|
Loading…
Reference in New Issue