diff --git a/src/main.cpp b/src/main.cpp index 286ef28b0..bb3c4d4dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5033,20 +5033,21 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta assert(pindexPrev); - int nHeight = pindexPrev->GetHeight()+1; - bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; + int daaForkHeight = GetArg("-daaforkheight", 448450); + int nHeight = pindexPrev->GetHeight()+1; + bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; // Check Proof-of-Work difficulty if (ishush3) { // The change of blocktime from 150s to 75s caused Weird Stuff in the difficulty/work calculations // caused by the fact that Difficulty Adjustment Algorithms do not take into account blocktime // changing at run-time, which breaks assumptions in the algorithm unsigned int nNextWork = GetNextWorkRequired(pindexPrev, &block, consensusParams); - //if ((nHeight < 340000 || nHeight > 342500) && block.nBits != nNextWork) { + //if ((nHeight < daaheight) && block.nBits != nNextWork) { if (block.nBits != nNextWork) { //cout << "Incorrect HUSH diffbits at height " << nHeight << // " " << block.nBits << " block.nBits vs. calc " << nNextWork << // " " << block.GetHash().ToString() << " @ " << block.GetBlockTime() << endl; - if (nHeight < 340000) { + if (nHeight < daaForkHeight) { return state.DoS(100, error("%s: Incorrect diffbits at height %d", __func__, nHeight), REJECT_INVALID, "bad-diffbits"); } else { LogPrintf("%s: Ignoring nbits calc : %lu vs block %lu\n",__func__, nNextWork, block.nBits ); diff --git a/src/pow.cpp b/src/pow.cpp index e51305faf..ad83a65a5 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -508,13 +508,10 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead // Changing this requires changing many other things and // changes consensus. Have fun -- Duke int64_t AveragingWindowTimespan(int32_t height) { - int64_t AWT = 2550; - /* - int32_t forkHeight = 0; - if (height >= forkHeight) { - AWT = 1275; - } - */ + // used in const methods, beware! + // This is the correct AWT for 75s blocktime, before block 340k + // the correct value was 2550 when the blocktime was 150s + int64_t AWT = 1275; return AWT; }