mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-03-13 06:01:45 +00:00
Litecoin: Fix zeitgeist2 attack thanks to Lolcust and ArtForz. This fixes an issue where a 51% attack can change difficulty at will. Go back the full period unless it's the first retarget after genesis.
This commit is contained in:
parent
7b0e39430b
commit
b1b31d15cc
@ -41,9 +41,15 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||||||
return pindexLast->nBits;
|
return pindexLast->nBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Litecoin: This fixes an issue where a 51% attack can change difficulty at will.
|
||||||
|
// Go back the full period unless it's the first retarget after genesis. Code courtesy of Art Forz
|
||||||
|
int blockstogoback = Params().Interval()-1;
|
||||||
|
if ((pindexLast->nHeight+1) != Params().Interval())
|
||||||
|
blockstogoback = Params().Interval();
|
||||||
|
|
||||||
// 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;
|
const CBlockIndex* pindexFirst = pindexLast;
|
||||||
for (int i = 0; pindexFirst && i < Params().Interval()-1; i++)
|
for (int i = 0; pindexFirst && i < blockstogoback; i++)
|
||||||
pindexFirst = pindexFirst->pprev;
|
pindexFirst = pindexFirst->pprev;
|
||||||
assert(pindexFirst);
|
assert(pindexFirst);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user