Calculate elapsed time using median instead of single block time

This commit is contained in:
myriadcoin
2015-02-23 11:47:12 +02:00
parent b339f11603
commit 7138dec7b1
2 changed files with 10 additions and 3 deletions
+9 -3
View File
@@ -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());
+1
View File
@@ -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