diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2015-03-26 11:06:27 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2015-03-26 11:06:27 -0700 |
commit | 1cc0e96e9cc7aa094ddee9fe5b192b3ac1a59da8 (patch) | |
tree | 04e5801264220c9037c5e870d3a6ba7278a6de1b /src/pow.cpp | |
parent | 8e4fd0cc315cad1e2925907ef7c62549a83730a5 (diff) |
Trivial optimization: use GetAncestor to compute new target
Diffstat (limited to 'src/pow.cpp')
-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); |