Fix assertion check in GetBlockSubsidy

This commit is contained in:
Kris Nuttycombe 2020-07-10 08:25:57 -06:00
parent 8f7861573d
commit 0e7ae06905
1 changed files with 2 additions and 4 deletions

View File

@ -911,8 +911,6 @@ bool ContextualCheckTransaction(
if (canopyActive) { if (canopyActive) {
fundingStreamElements = Consensus::GetActiveFundingStreamElements( fundingStreamElements = Consensus::GetActiveFundingStreamElements(
nHeight, nHeight,
// GetBlockSubsidy must be guarded because it will throw
// if called at slow-start period heights.
GetBlockSubsidy(nHeight, chainparams.GetConsensus()), GetBlockSubsidy(nHeight, chainparams.GetConsensus()),
chainparams.GetConsensus()); chainparams.GetConsensus());
} }
@ -1868,7 +1866,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
// Mining slow start // Mining slow start
// The subsidy is ramped up linearly, skipping the middle payout of // The subsidy is ramped up linearly, skipping the middle payout of
// MAX_SUBSIDY/2 to keep the monetary curve consistent with no slow start. // MAX_SUBSIDY/2 to keep the monetary curve consistent with no slow start.
if (nHeight < consensusParams.nSubsidySlowStartInterval / 2) { if (nHeight < consensusParams.SubsidySlowStartShift()) {
nSubsidy /= consensusParams.nSubsidySlowStartInterval; nSubsidy /= consensusParams.nSubsidySlowStartInterval;
nSubsidy *= nHeight; nSubsidy *= nHeight;
return nSubsidy; return nSubsidy;
@ -1878,7 +1876,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
return nSubsidy; return nSubsidy;
} }
assert(nHeight > consensusParams.SubsidySlowStartShift()); assert(nHeight >= consensusParams.SubsidySlowStartShift());
int halvings = consensusParams.Halving(nHeight); int halvings = consensusParams.Halving(nHeight);