mirror of
https://github.com/jwinterm/myriadcoin.git
synced 2026-10-24 06:48:35 +02:00
Calculate elapsed time using median instead of single block time
This commit is contained in:
+9
-3
@@ -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());
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user