Post
Topic
Board Altcoin Discussion
Re: Need Math for Halving Interval and Subsidy
by
marvic4
on 06/09/2020, 03:43:07 UTC

Code:
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
    ...
    // Force block reward to zero when right shift is undefined.
    if (halvings >= xxx) --------------Sample
        return 0;
    ...
}

That should be the following regardless of any of the parameters:

Code:
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
    ...
    // Force block reward to zero when right shift is undefined.
    if (halvings >= sizeof(nSubsidy) * CHAR_BIT)
        return 0;
    ...
}

In Bitcoin Core, they use the literal 64, which is ok until something changes and then it becomes a bug.

Thanks for replay.