aboutsummaryrefslogtreecommitdiff
path: root/src/dogecoin.cpp
diff options
context:
space:
mode:
authorPatrick Lodder <[email protected]>2015-07-20 15:03:02 +0200
committerPatrick Lodder <[email protected]>2015-07-20 15:03:02 +0200
commit8cd835cddba565594f5cde2d91ee92e32bcbf2fd (patch)
tree049698b334daf7e65af268b0da64134fd9dbbfdc /src/dogecoin.cpp
parentMerge pull request #1200 from rnicoll/1.10-auxpow-clean (diff)
parentUpdate Python test address and key values to match Dogecoin format. (diff)
downloaddiscoin-8cd835cddba565594f5cde2d91ee92e32bcbf2fd.tar.xz
discoin-8cd835cddba565594f5cde2d91ee92e32bcbf2fd.zip
Merge pull request #1201 from rnicoll/1.10-sync
Consensus fixes
Diffstat (limited to 'src/dogecoin.cpp')
-rw-r--r--src/dogecoin.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/dogecoin.cpp b/src/dogecoin.cpp
index dd394d5b4..6916982e0 100644
--- a/src/dogecoin.cpp
+++ b/src/dogecoin.cpp
@@ -16,21 +16,34 @@ 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;
- bool fNewDifficultyProtocol = (nHeight >= 145000);
- // bool fNewDifficultyProtocol = (nHeight >= params.GetDigiShieldForkBlock());
- const int64_t retargetTimespan = fNewDifficultyProtocol ? 60 // params.DigiShieldTargetTimespan()
- :
- params.nPowTargetTimespan;
-
+ const int64_t retargetTimespan = params.nPowTargetTimespan;
const int64_t nActualTimespan = pindexLast->GetBlockTime() - nFirstBlockTime;
int64_t nModulatedTimespan = nActualTimespan;
int64_t nMaxTimespan;
int64_t nMinTimespan;
- if (fNewDifficultyProtocol) //DigiShield implementation - thanks to RealSolid & WDC for this code
+ if (params.fDigishieldDifficultyCalculation) //DigiShield implementation - thanks to RealSolid & WDC for this code
{
// amplitude filter - thanks to daft27 for this code
nModulatedTimespan = retargetTimespan + (nModulatedTimespan - retargetTimespan) / 8;
@@ -66,12 +79,6 @@ unsigned int CalculateDogecoinNextWorkRequired(const CBlockIndex* pindexLast, in
if (bnNew > bnPowLimit)
bnNew = bnPowLimit;
- /// debug print
- LogPrintf("GetNextWorkRequired RETARGET\n");
- LogPrintf("params.nPowTargetTimespan = %d nActualTimespan = %d\n", params.nPowTargetTimespan, nActualTimespan);
- LogPrintf("Before: %08x %s\n", pindexLast->nBits, bnOld.ToString());
- LogPrintf("After: %08x %s\n", bnNew.GetCompact(), bnNew.ToString());
-
return bnNew.GetCompact();
}