Post
Topic
Board Development & Technical Discussion
Merits 1 from 1 user
Topic OP
Continuous & piecewise linear block reward function with 21M limit unchanged
by
uminatsu
on 12/03/2015, 17:01:07 UTC
⭐ Merited by ABCbits (1)
It is well known that the bitcoin block reward (as a function of the block number) is not continuous - a discontinuity ("halving") occurs every 210,000 blocks or roughly 4 years, as illustrated in the bitcoin source code:

Code:
CAmount GetBlockValue(int nHeight, const CAmount& nFees)
{
    CAmount nSubsidy = 50 * COIN;
    int halvings = nHeight / Params().SubsidyHalvingInterval();

    // Force block reward to zero when right shift is undefined.
    if (halvings >= 64)
        return nFees;

    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy >>= halvings;

    return nSubsidy + nFees;
}

IMHO the halvings are disruptive events and negatively affects everyone.

It isn't difficult to change the above code to make the block reward function continuous and piecewise linear while keeping the total limit of 21 million BTC unchanged. This would eliminate the discontinuity events in the future.

Proposed function is:

Code:
CAmount GetBlockValue(int nHeight, const CAmount& nFees)
{
    CAmount nSubsidy = 50 * COIN;
    int halvingInterval = Params().SubsidyHalvingInterval();
    int halvings = nHeight / halvingInterval;
    int phase = nHeight % halvingInterval;
   
    // Force block reward to zero when right shift is undefined.
    if (halvings >= 64)
        return nFees;

    // Subsidy is a continuous and piecewise linear function that halves every 210,000 blocks
    // which will occur approximately every 4 years.
    nSubsidy = (nSubsidy * (4 * halvingInterval - 2 * phase)) / (3 * halvingInterval);
    nSubsidy >>= halvings;

    return nSubsidy + nFees;
}