mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Trivial optimization: use GetAncestor to compute new target
This commit is contained in:
parent
8e4fd0cc31
commit
1cc0e96e9c
1 changed files with 3 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue