We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 27e8d22 + 1cc0e96 commit b36f1ceCopy full SHA for b36f1ce
src/pow.cpp
@@ -42,9 +42,9 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
42
}
43
44
// Go back by what we want to be 14 days worth of blocks
45
- const CBlockIndex* pindexFirst = pindexLast;
46
- for (int i = 0; pindexFirst && i < params.DifficultyAdjustmentInterval()-1; i++)
47
- pindexFirst = pindexFirst->pprev;
+ int nHeightFirst = pindexLast->nHeight - (params.DifficultyAdjustmentInterval()-1);
+ assert(nHeightFirst >= 0);
+ const CBlockIndex* pindexFirst = pindexLast->GetAncestor(nHeightFirst);
48
assert(pindexFirst);
49
50
return CalculateNextWorkRequired(pindexLast, pindexFirst->GetBlockTime(), params);
0 commit comments