Author

Topic: Need Math for Halving Interval and Subsidy (Read 159 times)

newbie
Activity: 27
Merit: 0
September 05, 2020, 11:43:07 PM
#7

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.
legendary
Activity: 4438
Merit: 3387
September 05, 2020, 09:46:12 PM
#6

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.
newbie
Activity: 27
Merit: 0
September 05, 2020, 09:42:24 AM
#5
Exactly 7391250, but you can round it to 7400000.
4 years = 126144000 seconds
126144000/600 = 210240 blocks per halving
30 years = 946080000 seconds
946080000/128 = 7391250 blocks per halving

Quote
30% premine
Ouch. It will fail.

Thanks,   
hero member
Activity: 813
Merit: 1944
September 05, 2020, 08:55:58 AM
#4
Exactly 7391250, but you can round it to 7400000.
4 years = 126144000 seconds
126144000/600 = 210240 blocks per halving
30 years = 946080000 seconds
946080000/128 = 7391250 blocks per halving

Quote
30% premine
Ouch. It will fail.
newbie
Activity: 27
Merit: 0
September 05, 2020, 07:20:53 AM
#3
when you keep getting stuck on basic things such as creating genesis block, mining a new block, setting block rewards, total supply,... (according to your post history) then maybe it is a sign that you are on a wrong path and should start by first learning what each of these topics you struggle with are and why they are designed like that instead of just trying to change variables and see which one works to create a new altcoin that has been created thousands of times before in the same exact way.

Thanks, for reading my previous posts, I am aware of basic things how to fork a coin(Older versions, few coins launched). But not expert Like YOU.
 
Those forked coins have lots of problems (newer versions ). I used to have Genesis tool generators,  which work for some coins and won't work most of the coins. That is main thing (tool generator)

That is the reason why i ask a question here. If your not interested in answering it is fine.

Now I asked simple Math,  Some one will help. I do help many devs.

Thanks.
legendary
Activity: 3472
Merit: 10611
September 05, 2020, 06:09:16 AM
#2
when you keep getting stuck on basic things such as creating genesis block, mining a new block, setting block rewards, total supply,... (according to your post history) then maybe it is a sign that you are on a wrong path and should start by first learning what each of these topics you struggle with are and why they are designed like that instead of just trying to change variables and see which one works to create a new altcoin that has been created thousands of times before in the same exact way.
newbie
Activity: 27
Merit: 0
September 05, 2020, 03:41:07 AM
#1
I Need a math here,

max_coin is 30M
30% premine,
30 Years reward goal,
Tragetspacing is 2 * 64 (128 sec)

So, I need to calculate Halving Interval (blocks)
consensus.nSubsidyHalvingInterval = ??


As per above data, how to modify this GetBlockSubsidy()


Code:
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
    if(nHeight <= consensusParams.nLastBigReward)
       ( return xxxxx * COIN;) --------Sample

    int halvings = (nHeight - consensusParams.nLastBigReward - 1) / consensusParams.nSubsidyHalvingInterval;
    // Force block reward to zero when right shift is undefined.
    if (halvings >= xxx) --------------Sample
        return 0;

    CAmount nSubsidy = xxx * COIN; -----------------Sample
    // Subsidy is cut in half every xxxxxx blocks which will occur approximately every 4 years.
    nSubsidy >>= halvings;
    return nSubsidy;
}


Thanks,
Jump to: