diff --git a/src/main.cpp b/src/main.cpp index c2afda88..fc3bcf44 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,36 +81,6 @@ namespace { { bool operator()(CBlockIndex *pa, CBlockIndex *pb) { - if ( (pa->nHeight >= nBlockAlgoNormalisedWorkStart2) || - (pb->nHeight >= nBlockAlgoNormalisedWorkStart2) ) - { - // First sort by most work per algo, ... - int aWins = 0, bWins = 0; - for (int i = 0; i < NUM_ALGOS; i++) - { - if (pa->nAlgoWork[i] > pb->nAlgoWork[i]) aWins++; - if (pa->nAlgoWork[i] < pb->nAlgoWork[i]) bWins++; - } - if (aWins > bWins) return false; - if (aWins < bWins) return true; - - // ... then by number of blocks ... - if (pa->nHeight > pb->nHeight) return false; - if (pa->nHeight < pb->nHeight) return true; - - // ... then by earliest time received, ... - if (pa->nSequenceId < pb->nSequenceId) return false; - if (pa->nSequenceId > pb->nSequenceId) return true; - - // Use pointer address as tie breaker (should only happen with blocks - // loaded from disk, as those all have id 0). - if (pa < pb) return false; - if (pa > pb) return true; - - // Identical blocks. - return false; - } - // First sort by most total work, ... if (pa->nChainWork > pb->nChainWork) return false; if (pa->nChainWork < pb->nChainWork) return true; @@ -2353,11 +2323,6 @@ bool AddToBlockIndex(CBlock& block, CValidationState& state, const CDiskBlockPos } pindexNew->nTx = block.vtx.size(); pindexNew->nChainWork = (pindexNew->pprev ? pindexNew->pprev->nChainWork : 0) + pindexNew->GetBlockWorkAdjusted().getuint256(); - for (int i = 0; i < NUM_ALGOS; i++) - { - pindexNew->nAlgoWork[i] = (pindexNew->pprev ? pindexNew->pprev->nAlgoWork[i] : 0) + - (i == pindexNew->GetAlgo() ? pindexNew->GetBlockWork().getuint256() : 0); - } pindexNew->nChainTx = (pindexNew->pprev ? pindexNew->pprev->nChainTx : 0) + pindexNew->nTx; pindexNew->nFile = pos.nFile; pindexNew->nDataPos = pos.nPos; diff --git a/src/main.h b/src/main.h index 57b91c81..9ca020d0 100644 --- a/src/main.h +++ b/src/main.h @@ -689,7 +689,6 @@ 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 nBlockAlgoNormalisedWorkStart2 = 99990000; // block where algo combined weight starts with decay 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 @@ -727,8 +726,6 @@ public: // (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block uint256 nChainWork; - uint256 nAlgoWork[NUM_ALGOS]; - // Number of transactions in this block. // Note: in a potential headers-first mode, this number cannot be relied upon unsigned int nTx; @@ -758,8 +755,6 @@ public: nDataPos = 0; nUndoPos = 0; nChainWork = 0; - for (int i = 0; i < NUM_ALGOS; i++) - nAlgoWork[i] = 0; nTx = 0; nChainTx = 0; nStatus = 0; @@ -781,8 +776,6 @@ public: nDataPos = 0; nUndoPos = 0; nChainWork = 0; - for (int i = 0; i < NUM_ALGOS; i++) - nAlgoWork[i] = 0; nTx = 0; nChainTx = 0; nStatus = 0; @@ -852,31 +845,6 @@ public: return Params().ProofOfWorkLimit(algo); } - CBigNum GetPrevWorkForAlgoWithDecay(int algo) const - { - int nDistance = 0; - CBlockIndex* pindex = this->pprev; - while (pindex) - { - if (nDistance > 32) - { - return Params().ProofOfWorkLimit(algo); - } - if (pindex->GetAlgo() == algo) - { - CBigNum nWork = pindex->GetBlockWork(); - nWork *= (32 - nDistance); - nWork /= 32; - if (nWork < Params().ProofOfWorkLimit(algo)) - nWork = Params().ProofOfWorkLimit(algo); - return nWork; - } - pindex = pindex->pprev; - nDistance++; - } - return Params().ProofOfWorkLimit(algo); - } - CBigNum GetBlockWork() const { CBigNum bnTarget; @@ -928,10 +896,7 @@ public: { if (algo != nAlgo) { - if (nHeight >= nBlockAlgoNormalisedWorkStart2) - nBlockWork += GetPrevWorkForAlgoWithDecay(algo); - else - nBlockWork += GetPrevWorkForAlgo(algo); + nBlockWork += GetPrevWorkForAlgo(algo); } } bnRes = nBlockWork / NUM_ALGOS;