Browse Source

Merge pull request #5948

1cc0e96 Trivial optimization: use GetAncestor to compute new target (Pieter Wuille)
0.13
Pieter Wuille 10 years ago
parent
commit
b36f1ce87e
No known key found for this signature in database
GPG Key ID: 57896D2FF8F0B657
  1. 6
      src/pow.cpp

6
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 // Go back by what we want to be 14 days worth of blocks
const CBlockIndex* pindexFirst = pindexLast; int nHeightFirst = pindexLast->nHeight - (params.DifficultyAdjustmentInterval()-1);
for (int i = 0; pindexFirst && i < params.DifficultyAdjustmentInterval()-1; i++) assert(nHeightFirst >= 0);
pindexFirst = pindexFirst->pprev; const CBlockIndex* pindexFirst = pindexLast->GetAncestor(nHeightFirst);
assert(pindexFirst); assert(pindexFirst);
return CalculateNextWorkRequired(pindexLast, pindexFirst->GetBlockTime(), params); return CalculateNextWorkRequired(pindexLast, pindexFirst->GetBlockTime(), params);

Loading…
Cancel
Save