aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chainparams.cpp2
-rw-r--r--src/pow.cpp8
2 files changed, 8 insertions, 2 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 68030d6ab..e85e26922 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -332,7 +332,7 @@ public:
consensus.nRuleChangeActivationThreshold = 1900; // 95% of 2000
consensus.nMinerConfirmationWindow = 2000; // nPowTargetTimespan / nPowTargetSpacing
consensus.MinBIP9WarningHeight = 0;
- consensus.powLimit = uint256S("00000377ae000000000000000000000000000000000000000000000000000000");
+ consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
diff --git a/src/pow.cpp b/src/pow.cpp
index 1414d3756..70c61e77d 100644
--- a/src/pow.cpp
+++ b/src/pow.cpp
@@ -37,8 +37,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);