aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorJannis Froese <[email protected]>2014-03-24 03:14:37 +0100
committerJannis Froese <[email protected]>2014-03-24 03:28:06 +0100
commit1943494138f0249734043ebbde9c512df6ebeae3 (patch)
tree855dc76ddc07a517a564ba5b6f098118bf76d419 /src/main.cpp
parentMerge pull request #361 from leofidus/bloom-todd (diff)
downloaddiscoin-1943494138f0249734043ebbde9c512df6ebeae3.tar.xz
discoin-1943494138f0249734043ebbde9c512df6ebeae3.zip
additional Dogecoin 1.6 changes
(cherry picked from commit 6d46c53acf957e33e3940a8db009cc406a3f6b9c)
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp54
1 files changed, 13 insertions, 41 deletions
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)
+ else if(nHeight < 600000)
{
- cseed_str = prevHash.ToString().substr(7,7);
- cseed = cseed_str.c_str();
- seed = hex2long(cseed);
- rand4 = generateMTRandom(seed, 62499);
- nSubsidy = (1 + rand4) * COIN;
+ nSubsidy >>= (nHeight / 100000);
}
- else if(nHeight < 600000)
+ else
{
- cseed_str = prevHash.ToString().substr(6,7);
- cseed = cseed_str.c_str();
- seed = hex2long(cseed);
- rand5 = generateMTRandom(seed, 31249);
- nSubsidy = (1 + rand5) * COIN;
+ 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());