Sync changes from Dogecoin 1.10
This commit is contained in:
parent
fcde864334
commit
1de15c70ce
|
@ -16,6 +16,24 @@ int static generateMTRandom(unsigned int s, int range)
|
|||
return dist(gen);
|
||||
}
|
||||
|
||||
// Dogecoin: Normally minimum difficulty blocks can only occur in between
|
||||
// retarget blocks. However, once we introduce Digishield every block is
|
||||
// a retarget, so we need to handle minimum difficulty on all blocks.
|
||||
bool AllowDigishieldMinDifficultyForBlock(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||
{
|
||||
// check if the chain allows minimum difficulty blocks
|
||||
if (!params.fPowAllowMinDifficultyBlocks)
|
||||
return false;
|
||||
|
||||
// check if the chain allows minimum difficulty blocks on recalc blocks
|
||||
if (pindexLast->nHeight < 157500)
|
||||
// if (!params.fPowAllowDigishieldMinDifficultyBlocks)
|
||||
return false;
|
||||
|
||||
// Allow for a minimum block time if the elapsed time > 2*nTargetSpacing
|
||||
return (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2);
|
||||
}
|
||||
|
||||
unsigned int CalculateDogecoinNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params)
|
||||
{
|
||||
int nHeight = pindexLast->nHeight + 1;
|
||||
|
@ -88,8 +106,7 @@ bool CheckAuxPowProofOfWork(const CBlockHeader& block, const Consensus::Params&
|
|||
params.nAuxpowChainId, block.nVersion);
|
||||
|
||||
/* If there is no auxpow, just check the block hash. */
|
||||
if (!block.auxpow)
|
||||
{
|
||||
if (!block.auxpow) {
|
||||
if (block.IsAuxpow())
|
||||
return error("%s : no auxpow on block with auxpow version",
|
||||
__func__);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "chain.h"
|
||||
#include "chainparams.h"
|
||||
|
||||
bool AllowDigishieldMinDifficultyForBlock(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params);
|
||||
CAmount GetDogecoinBlockSubsidy(int nHeight, const Consensus::Params& consensusParams, uint256 prevHash);
|
||||
unsigned int CalculateDogecoinNextWorkRequired(const CBlockIndex* pindexLast, int64_t nLastRetargetTime, const Consensus::Params& params);
|
||||
|
||||
|
|
15
src/pow.cpp
15
src/pow.cpp
|
@ -21,8 +21,21 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||
if (pindexLast == NULL)
|
||||
return nProofOfWorkLimit;
|
||||
|
||||
// Dogecoin: Special rules for minimum difficulty blocks with Digishield
|
||||
if (AllowDigishieldMinDifficultyForBlock(pindexLast, pblock, params))
|
||||
{
|
||||
// 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.
|
||||
return nProofOfWorkLimit;
|
||||
}
|
||||
|
||||
// Only change once per difficulty adjustment interval
|
||||
if ((pindexLast->nHeight+1) % params.DifficultyAdjustmentInterval() != 0)
|
||||
bool fNewDifficultyProtocol = (pindexLast->nHeight >= 145000);
|
||||
const int64_t difficultyAdjustmentInterval = fNewDifficultyProtocol
|
||||
? 1
|
||||
: params.DifficultyAdjustmentInterval();
|
||||
if ((pindexLast->nHeight+1) % difficultyAdjustmentInterval != 0)
|
||||
{
|
||||
if (params.fPowAllowMinDifficultyBlocks)
|
||||
{
|
||||
|
|
|
@ -362,7 +362,9 @@ BOOST_AUTO_TEST_CASE(auxpow_pow)
|
|||
mineBlock(block, true);
|
||||
BOOST_CHECK(CheckAuxPowProofOfWork(block, params));
|
||||
|
||||
block.nVersion = 2;
|
||||
// Dogecoin block version 2 can be both AuxPoW and regular, so test 3
|
||||
|
||||
block.nVersion = 3;
|
||||
mineBlock(block, true);
|
||||
BOOST_CHECK(!CheckAuxPowProofOfWork(block, params));
|
||||
|
||||
|
|
Loading…
Reference in a new issue