aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorJannis Froese <[email protected]>2014-03-22 07:33:44 +0100
committerJannis Froese <[email protected]>2014-03-22 22:13:27 +0100
commitc5eb32a85beeec07dc4ebea3788a63da23df9dff (patch)
tree84fef9447f37d8be8f4167df724967a115498976 /src/main.cpp
parentfix makefile (diff)
downloaddiscoin-c5eb32a85beeec07dc4ebea3788a63da23df9dff.tar.xz
discoin-c5eb32a85beeec07dc4ebea3788a63da23df9dff.zip
updated to Dogecoin 1.6 protocol
(cherry picked from commit d6dbaf412e2331426d5012d1c10b7749b6821b82)
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f4159e269..2cfe9a6e3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1184,9 +1184,12 @@ int64_t GetBlockValue(int nHeight, int64_t nFees, uint256 prevHash)
}
static const int64_t nTargetTimespan = 4 * 60 * 60; // DogeCoin: every 4 hours
+static const int64_t nTargetTimespanNEW = 60 ; // DogeCoin: every 1 minute
static const int64_t nTargetSpacing = 60; // DogeCoin: 1 minute
static const int64_t nInterval = nTargetTimespan / nTargetSpacing;
+static const int64_t nDiffChangeTarget = 145000; // Patch effective @ block 145000
+
//
// minimum amount of work that could possibly be required nTime after
// minimum work required was nBase
@@ -1217,6 +1220,18 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
{
unsigned int nProofOfWorkLimit = Params().ProofOfWorkLimit().GetCompact();
+ int nHeight = pindexLast->nHeight + 1;
+ bool fNewDifficultyProtocol = (nHeight >= nDiffChangeTarget);
+
+ int64_t retargetTimespan = nTargetTimespan;
+ int64_t retargetSpacing = nTargetSpacing;
+ int64_t retargetInterval = nInterval;
+
+ if (fNewDifficultyProtocol) {
+ retargetInterval = nTargetTimespanNEW / nTargetSpacing;
+ retargetTimespan = nTargetTimespanNEW;
+ }
+
// Genesis block
if (pindexLast == NULL)
return nProofOfWorkLimit;
@@ -1257,15 +1272,23 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
// Limit adjustment step
int64_t nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
- //printf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
- if(pindexLast->nHeight+1 > 10000)
+ LogPrintf(" nActualTimespan = %d before bounds\n", nActualTimespan);
+
+ if (fNewDifficultyProtocol) //DigiShield implementation - thanks to RealSolid & WDC for this code
{
+ // amplitude filter - thanks to daft27 for this code
+ nActualTimespan = retargetTimespan + (nActualTimespan - retargetTimespan)/8;
+ printf("DIGISHIELD RETARGET\n");
+ if (nActualTimespan < (retargetTimespan - (retargetTimespan/4)) ) nActualTimespan = (retargetTimespan - (retargetTimespan/4));
+ if (nActualTimespan > (retargetTimespan + (retargetTimespan/2)) ) nActualTimespan = (retargetTimespan + (retargetTimespan/2));
+ }
+ else if (pindexLast->nHeight+1 > 10000) {
if (nActualTimespan < nTargetTimespan/4)
nActualTimespan = nTargetTimespan/4;
if (nActualTimespan > nTargetTimespan*4)
nActualTimespan = nTargetTimespan*4;
}
- else if(pindexLast->nHeight+1 > 5000)
+ else if (pindexLast->nHeight+1 > 5000)
{
if (nActualTimespan < nTargetTimespan/8)
nActualTimespan = nTargetTimespan/8;
@@ -1549,7 +1572,10 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, CCoinsViewCach
// If prev is coinbase, check that it's matured
if (coins.IsCoinBase()) {
- if (nSpendHeight - coins.nHeight < COINBASE_MATURITY)
+ int minDepth = COINBASE_MATURITY;
+ if(coins.nHeight >= COINBASE_MATURITY_SWITCH)
+ minDepth = COINBASE_MATURITY_NEW;
+ if (nSpendHeight - coins.nHeight < minDepth)
return state.Invalid(
error("CheckInputs() : tried to spend coinbase at depth %d", nSpendHeight - coins.nHeight),
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase");