Merge pull request #5948

1cc0e96 Trivial optimization: use GetAncestor to compute new target (Pieter Wuille)
This commit is contained in:
Pieter Wuille 2015-04-07 15:10:44 -07:00
commit b36f1ce87e
No known key found for this signature in database
GPG Key ID: 57896D2FF8F0B657
1 changed files with 3 additions and 3 deletions

View File

@ -42,9 +42,9 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
}
// Go back by what we want to be 14 days worth of blocks
const CBlockIndex* pindexFirst = pindexLast;
for (int i = 0; pindexFirst && i < params.DifficultyAdjustmentInterval()-1; i++)
pindexFirst = pindexFirst->pprev;
int nHeightFirst = pindexLast->nHeight - (params.DifficultyAdjustmentInterval()-1);
assert(nHeightFirst >= 0);
const CBlockIndex* pindexFirst = pindexLast->GetAncestor(nHeightFirst);
assert(pindexFirst);
return CalculateNextWorkRequired(pindexLast, pindexFirst->GetBlockTime(), params);