Merge pull request #589 from patricklodder/1.8-dev-testnet-retarget

Break testnet difficulty reset out of never matching condition.
This commit is contained in:
langerhans 2014-08-04 19:10:17 +02:00
commit 553a17edaa

View file

@ -1299,17 +1299,18 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
if (pindexLast == NULL)
return nProofOfWorkLimit;
// Only change once per interval
if ((pindexLast->nHeight+1) % retargetInterval != 0)
{
if (TestNet())
if (TestNet() && pblock->nTime > pindexLast->nTime + nTargetSpacing*2)
{
// Special difficulty rule for testnet:
// If the new block's timestamp is more than 2* nTargetSpacing minutes
// then allow mining of a min-difficulty block.
if (pblock->nTime > pindexLast->nTime + nTargetSpacing*2)
return nProofOfWorkLimit;
else
}
// Only change once per interval
if ((pindexLast->nHeight+1) % retargetInterval != 0)
{
if (TestNet())
{
// Return the last non-special-min-difficulty-rules-block
const CBlockIndex* pindex = pindexLast;
@ -1317,7 +1318,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
pindex = pindex->pprev;
return pindex->nBits;
}
}
return pindexLast->nBits;
}