Post
Topic
Board Announcements (Altcoins)
Re: Dagra
by
phinx
on 10/04/2017, 05:36:39 UTC
int64_t GetBlockValue(int nBits, int nHeight, const CAmount& nFees)
{
    double dDiff = (double)0x0000ffff / (double)(nBits & 0x00ffffff);

    /* fixed bug caused diff to not be correctly calculated */
    if(nHeight > 4500 || Params().NetworkID() != CBaseChainParams::MAIN) dDiff = ConvertBitsToDouble(nBits);

    int64_t nSubsidy = 0;
    if(nHeight >= 5465) {
        if((nHeight >= 17000 && dDiff > 75) || nHeight >= 24000) { // GPU/ASIC difficulty calc
            // 2222222/(((x+2600)/9)^2)
            nSubsidy = (2222222.0 / (pow((dDiff+2600.0)/9.0,2.0)));
            if (nSubsidy > 25) nSubsidy = 25;
            if (nSubsidy < 5) nSubsidy = 5;
        } else { // CPU mining calc
            nSubsidy = (11111.0 / (pow((dDiff+51.0)/6.0,2.0)));
            if (nSubsidy > 500) nSubsidy = 500;
            if (nSubsidy < 25) nSubsidy = 25;
        }
    } else {
        nSubsidy = (1111.0 / (pow((dDiff+1.0),2.0)));
        if (nSubsidy > 500) nSubsidy = 500;
        if (nSubsidy < 1) nSubsidy = 1;
    }

    // LogPrintf("height %u diff %4.2f reward %i \n", nHeight, dDiff, nSubsidy);
    nSubsidy *= COIN;

    if(Params().NetworkID() == CBaseChainParams::TESTNET){
        for(int i = 46200; i <= nHeight; i += 210240) nSubsidy -= nSubsidy/14;
    } else {
        // yearly decline of production by 7.1% per year, projected 21.3M coins max by year 2050.
        for(int i = 210240; i <= nHeight; i += 210240) nSubsidy -= nSubsidy/14;
    }

    // block reward can not be less than one DAGRA
    if(nSubsidy < COIN) nSubsidy = COIN;
   
    /*
        Hard fork will activate on block 34560, reducing the block reward by 10 extra percent (allowing budget super-blocks)
    */
           
    if(Params().NetworkID() == CBaseChainParams::TESTNET){
        if(nHeight > 8064) nSubsidy -= nSubsidy / 10;
    } else {
        if(nHeight > 34560) nSubsidy -= nSubsidy / 10; // 34560 - 10.0% - launch the budget system  60 days after system start
    }
   
    return nSubsidy + nFees;
}

int64_t GetMasternodePayment(int nHeight, int64_t blockValue)
{
    int64_t ret = blockValue/5; // start at 20%

    if(Params().NetworkID() == CBaseChainParams::TESTNET) {
        if(nHeight > 46000)             ret += blockValue / 20; //25% - 2014-10-07
        if(nHeight > 46000+((576*1)*1)) ret += blockValue / 20; //30% - 2014-10-08
        if(nHeight > 46000+((576*1)*2)) ret += blockValue / 20; //35% - 2014-10-09
        if(nHeight > 46000+((576*1)*3)) ret += blockValue / 20; //40% - 2014-10-10
        if(nHeight > 46000+((576*1)*4)) ret += blockValue / 20; //45% - 2014-10-11
        if(nHeight > 46000+((576*1)*5)) ret += blockValue / 20; //50% - 2014-10-12
        if(nHeight > 46000+((576*1)*6)) ret += blockValue / 20; //55% - 2014-10-13
        if(nHeight > 46000+((576*1)*7)) ret += blockValue / 20; //60% - 2014-10-14
    }

    if(nHeight > 158000)               ret += blockValue / 20; // 158000 - 25.0% - 2014-10-24
    if(nHeight > 158000+((576*30)* 1)) ret += blockValue / 20; // 175280 - 30.0% - 2014-11-25
    if(nHeight > 158000+((576*30)* 2)) ret += blockValue / 20; // 192560 - 35.0% - 2014-12-26
    if(nHeight > 158000+((576*30)* 3)) ret += blockValue / 40; // 209840 - 37.5% - 2015-01-26
    if(nHeight > 158000+((576*30)* 4)) ret += blockValue / 40; // 227120 - 40.0% - 2015-02-27
    if(nHeight > 158000+((576*30)* 5)) ret += blockValue / 40; // 244400 - 42.5% - 2015-03-30
    if(nHeight > 158000+((576*30)* 6)) ret += blockValue / 40; // 261680 - 45.0% - 2015-05-01
    if(nHeight > 158000+((576*30)* 7)) ret += blockValue / 40; // 278960 - 47.5% - 2015-06-01
    if(nHeight > 158000+((576*30)* 9)) ret += blockValue / 40; // 313520 - 50.0% - 2015-08-03

    /*
        Hard for will activate on block 348080 separating the two networks (v11 and earier and v12)
        if(nHeight > 158000+((576*30)*11)) ret += blockValue / 40; // 348080 - 52.5% - 2015-10-05
        if(nHeight > 158000+((576*30)*13)) ret += blockValue / 40; // 382640 - 55.0% - 2015-12-07
        if(nHeight > 158000+((576*30)*15)) ret += blockValue / 40; // 417200 - 57.5% - 2016-02-08
        if(nHeight > 158000+((576*30)*17)) ret += blockValue / 40; // 451760 - 60.0% - 2016-04-11
    */

    return ret;
}


i checked the source code,Looks pretty good,i'm in.