diff --git a/src/main.cpp b/src/main.cpp index c625346f..7ab0be13 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1325,7 +1325,8 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead const CBlockIndex* pindexFirst = NULL; - if (pindexLast->nHeight >= nBlockTimeWarpPreventStart2) + if ( (pindexLast->nHeight >= nBlockTimeWarpPreventStart2) && + (pindexLast->nHeight < nBlockTimeWarpPreventStart3) ) { // find first block in averaging interval // Go back by what we want to be nAveragingInterval blocks @@ -1359,7 +1360,8 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead } } else - if (pindexLast->nHeight >= nBlockTimeWarpPreventStart) + if ( (pindexLast->nHeight >= nBlockTimeWarpPreventStart) && + (pindexLast->nHeight < nBlockTimeWarpPreventStart2) ) { // find first block in averaging interval // Go back by what we want to be nAveragingInterval blocks @@ -1401,7 +1403,11 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead } // Limit adjustment step - int64_t nActualTimespan = pindexPrev->GetBlockTime() - pindexFirst->GetBlockTime(); + int64_t nActualTimespan; + if (pindexLast->nHeight >= nBlockTimeWarpPreventStart3) + nActualTimespan = pindexPrev->GetMedianTimePast() - pindexFirst->GetMedianTimePast(); + else + nActualTimespan = pindexPrev->GetBlockTime() - pindexFirst->GetBlockTime(); LogPrintf(" nActualTimespan = %d before bounds %d %d\n", nActualTimespan, pindexPrev->GetBlockTime(), pindexFirst->GetBlockTime()); diff --git a/src/main.h b/src/main.h index 225c4a56..96cda99d 100644 --- a/src/main.h +++ b/src/main.h @@ -698,6 +698,7 @@ const int nBlockSequentialAlgoMaxCount2 = 3; // maximum sequential blocks of sam const int64_t nBlockTimeWarpPreventStart = 740500; // block where time warp 1 prevention starts const int64_t nBlockTimeWarpPreventStart2 = 766000; // block where time warp 2 prevention starts const int64_t nBlockDiffAdjustV2 = 766000; // block where difficulty adjust V2 starts +const int64_t nBlockTimeWarpPreventStart3 = 1048320; // block where time warp 3 prevention starts /** The block chain is a tree shaped structure starting with the * genesis block at the root, with each block potentially having multiple