Rename CClaimTrieCache to CClaimTrieUpdateBuffer #156
1 changed files with 8 additions and 19 deletions
27
src/pow.cpp
27
src/pow.cpp
|
@ -14,31 +14,20 @@
|
||||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();
|
unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();
|
||||||
|
|
||||||
// Genesis block
|
// Genesis block
|
||||||
if (pindexLast == NULL)
|
if (pindexLast == NULL)
|
||||||
return nProofOfWorkLimit;
|
return nProofOfWorkLimit;
|
||||||
|
|
||||||
// Only change once per difficulty adjustment interval
|
if (params.fPowAllowMinDifficultyBlocks)
|
||||||
if ((pindexLast->nHeight+1) % params.DifficultyAdjustmentInterval() != 0)
|
|
||||||
{
|
{
|
||||||
if (params.fPowAllowMinDifficultyBlocks)
|
// Special difficulty rule for testnet:
|
||||||
{
|
// If the new block's timestamp is twice the target block time
|
||||||
// Special difficulty rule for testnet:
|
// then allow mining of a min-difficulty block.
|
||||||
// If the new block's timestamp is more than 2* 10 minutes
|
// This is to prevent the testnet from gettig stuck when a large amount
|
||||||
// then allow mining of a min-difficulty block.
|
// of hashrate drops off the network.
|
||||||
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2)
|
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2){
|
||||||
return nProofOfWorkLimit;
|
return nProofOfWorkLimit;
|
||||||
else
|
|
||||||
{
|
|
||||||
// Return the last non-special-min-difficulty-rules-block
|
|
||||||
const CBlockIndex* pindex = pindexLast;
|
|
||||||
while (pindex->pprev && pindex->nHeight % params.DifficultyAdjustmentInterval() != 0 && pindex->nBits == nProofOfWorkLimit)
|
|
||||||
pindex = pindex->pprev;
|
|
||||||
return pindex->nBits;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return pindexLast->nBits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go back the full period unless it's the first retarget after genesis.
|
// Go back the full period unless it's the first retarget after genesis.
|
||||||
|
|
Loading…
Reference in a new issue