mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 13:59:06 +01: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
db4d8e21d9
commit
164ae00f46
@ -1136,9 +1136,15 @@ unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBl
|
||||
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 = nInterval-1;
|
||||
if ((pindexLast->nHeight+1) != nInterval)
|
||||
blockstogoback = nInterval;
|
||||
|
||||
// Go back by what we want to be 14 days worth of blocks
|
||||
const CBlockIndex* pindexFirst = pindexLast;
|
||||
for (int i = 0; pindexFirst && i < nInterval-1; i++)
|
||||
for (int i = 0; pindexFirst && i < blockstogoback; i++)
|
||||
pindexFirst = pindexFirst->pprev;
|
||||
assert(pindexFirst);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user