diff --git a/src/main.cpp b/src/main.cpp index 4ad43fbce..22886473a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1126,23 +1126,19 @@ int static generateMTRandom(unsigned int s, int range) int64_t GetBlockValue(int nHeight, int64_t nFees, uint256 prevHash) { - int64_t nSubsidy = 10000 * COIN; + int64_t nSubsidy = 500000 * COIN; std::string cseed_str = prevHash.ToString().substr(7,7); const char* cseed = cseed_str.c_str(); long seed = hex2long(cseed); int rand = generateMTRandom(seed, 999999); int rand1 = 0; - int rand2 = 0; - int rand3 = 0; - int rand4 = 0; - int rand5 = 0; if(nHeight < 100000) { nSubsidy = (1 + rand) * COIN; } - else if(nHeight < 200000) + else if(nHeight < 145000) { cseed_str = prevHash.ToString().substr(7,7); cseed = cseed_str.c_str(); @@ -1150,37 +1146,13 @@ int64_t GetBlockValue(int nHeight, int64_t nFees, uint256 prevHash) rand1 = generateMTRandom(seed, 499999); nSubsidy = (1 + rand1) * COIN; } - else if(nHeight < 300000) - { - cseed_str = prevHash.ToString().substr(6,7); - cseed = cseed_str.c_str(); - seed = hex2long(cseed); - rand2 = generateMTRandom(seed, 249999); - nSubsidy = (1 + rand2) * COIN; - } - else if(nHeight < 400000) - { - cseed_str = prevHash.ToString().substr(7,7); - cseed = cseed_str.c_str(); - seed = hex2long(cseed); - rand3 = generateMTRandom(seed, 124999); - nSubsidy = (1 + rand3) * COIN; - } - else if(nHeight < 500000) - { - cseed_str = prevHash.ToString().substr(7,7); - cseed = cseed_str.c_str(); - seed = hex2long(cseed); - rand4 = generateMTRandom(seed, 62499); - nSubsidy = (1 + rand4) * COIN; - } else if(nHeight < 600000) { - cseed_str = prevHash.ToString().substr(6,7); - cseed = cseed_str.c_str(); - seed = hex2long(cseed); - rand5 = generateMTRandom(seed, 31249); - nSubsidy = (1 + rand5) * COIN; + nSubsidy >>= (nHeight / 100000); + } + else + { + nSubsidy = 10000 * COIN; } return nSubsidy + nFees; @@ -1248,7 +1220,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead return nProofOfWorkLimit; // Only change once per interval - if ((pindexLast->nHeight+1) % nInterval != 0) + if ((pindexLast->nHeight+1) % retargetInterval != 0) { if (TestNet()) { @@ -1261,7 +1233,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead { // Return the last non-special-min-difficulty-rules-block const CBlockIndex* pindex = pindexLast; - while (pindex->pprev && pindex->nHeight % nInterval != 0 && pindex->nBits == nProofOfWorkLimit) + while (pindex->pprev && pindex->nHeight % retargetInterval != 0 && pindex->nBits == nProofOfWorkLimit) pindex = pindex->pprev; return pindex->nBits; } @@ -1271,9 +1243,9 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead // Dogecoin: This fixes an issue where a 51% attack can change difficulty at will. // Go back the full period unless it's the first retarget after genesis. Code courtesy of Art Forz - int blockstogoback = nInterval-1; - if ((pindexLast->nHeight+1) != nInterval) - blockstogoback = nInterval; + int blockstogoback = retargetInterval-1; + if ((pindexLast->nHeight+1) != retargetInterval) + blockstogoback = retargetInterval; // Go back by what we want to be 14 days worth of blocks const CBlockIndex* pindexFirst = pindexLast; @@ -1318,14 +1290,14 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead CBigNum bnNew; bnNew.SetCompact(pindexLast->nBits); bnNew *= nActualTimespan; - bnNew /= nTargetTimespan; + bnNew /= retargetTimespan; if (bnNew > Params().ProofOfWorkLimit()) bnNew = Params().ProofOfWorkLimit(); /// debug print LogPrintf("GetNextWorkRequired RETARGET\n"); - LogPrintf("nTargetTimespan = %d nActualTimespan = %d\n", nTargetTimespan, nActualTimespan); + LogPrintf("nTargetTimespan = %d nActualTimespan = %d\n", retargetTimespan, nActualTimespan); LogPrintf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString()); LogPrintf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString());