diff --git a/src/main.h b/src/main.h index ec96a0c1..225c4a56 100644 --- a/src/main.h +++ b/src/main.h @@ -690,6 +690,7 @@ enum BlockStatus { const int64_t nBlockAlgoWorkWeightStart = 142000; // block where algo work weighting starts const int64_t nBlockAlgoNormalisedWorkStart = 740000; // block where algo combined weight starts const int64_t nBlockAlgoNormalisedWorkDecayStart = 866000; // block where weight decay starts +const int64_t nBlockAlgoNormalisedWorkDecayStart2 = 932000; // block where weight decay starts const int64_t nBlockSequentialAlgoRuleStart = 740000; // block where sequential algo rule starts const int64_t nBlockSequentialAlgoRuleStart2 = 766000; // block where sequential algo rule starts const int nBlockSequentialAlgoMaxCount = 6; // maximum sequential blocks of same algo @@ -878,6 +879,30 @@ public: return Params().ProofOfWorkLimit(algo); } + CBigNum GetPrevWorkForAlgoWithDecay2(int algo) const + { + int nDistance = 0; + CBigNum nWork; + CBlockIndex* pindex = this->pprev; + while (pindex) + { + if (nDistance > 32) + { + return CBigNum(0); + } + if (pindex->GetAlgo() == algo) + { + CBigNum nWork = pindex->GetBlockWork(); + nWork *= (32 - nDistance); + nWork /= 32; + return nWork; + } + pindex = pindex->pprev; + nDistance++; + } + return CBigNum(0); + } + CBigNum GetBlockWork() const { CBigNum bnTarget; @@ -929,10 +954,13 @@ public: { if (algo != nAlgo) { - if (nHeight >= nBlockAlgoNormalisedWorkDecayStart) - nBlockWork += GetPrevWorkForAlgoWithDecay(algo); + if (nHeight >= nBlockAlgoNormalisedWorkDecayStart2) + nBlockWork += GetPrevWorkForAlgoWithDecay2(algo); else - nBlockWork += GetPrevWorkForAlgo(algo); + if (nHeight >= nBlockAlgoNormalisedWorkDecayStart) + nBlockWork += GetPrevWorkForAlgoWithDecay(algo); + else + nBlockWork += GetPrevWorkForAlgo(algo); } } bnRes = nBlockWork / NUM_ALGOS;