diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2015-04-07 15:10:44 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2015-04-07 15:13:04 -0700 |
commit | b36f1ce87ed322f1d044e1f5a8258b64042706d6 (patch) | |
tree | 5e357917c29f22ab07074d9796932973a1ad0bd3 /src | |
parent | 27e8d224e9d7577a2c25a26eb5e40ed0b25a6280 (diff) | |
parent | 1cc0e96e9cc7aa094ddee9fe5b192b3ac1a59da8 (diff) |
Merge pull request #5948
1cc0e96 Trivial optimization: use GetAncestor to compute new target (Pieter Wuille)
Diffstat (limited to 'src')
-rw-r--r-- | src/pow.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/pow.cpp b/src/pow.cpp index 3c5a8d9d96..cf7ac387f2 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -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); |