diff options
| author | coblee <[email protected]> | 2011-10-09 20:46:21 -1000 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2015-07-19 16:42:23 +0000 |
| commit | 106ecab0e0c8c33a2a601afd8c42cac2e6b80e0c (patch) | |
| tree | c17f6a53b6525c7571483f3b719b922975671c3d /src/pow.cpp | |
| parent | Minor Dogecoin consensus fixes (diff) | |
| download | discoin-106ecab0e0c8c33a2a601afd8c42cac2e6b80e0c.tar.xz discoin-106ecab0e0c8c33a2a601afd8c42cac2e6b80e0c.zip | |
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.
Diffstat (limited to 'src/pow.cpp')
| -rw-r--r-- | src/pow.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pow.cpp b/src/pow.cpp index a0fac9219..1dac0b81c 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -51,8 +51,14 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead 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.DifficultyAdjustmentInterval()-1; + if ((pindexLast->nHeight+1) != params.DifficultyAdjustmentInterval()) + blockstogoback = params.DifficultyAdjustmentInterval(); + // Go back by what we want to be 14 days worth of blocks - int nHeightFirst = pindexLast->nHeight - (params.DifficultyAdjustmentInterval()-1); + int nHeightFirst = pindexLast->nHeight - blockstogoback; assert(nHeightFirst >= 0); const CBlockIndex* pindexFirst = pindexLast->GetAncestor(nHeightFirst); assert(pindexFirst); |