From b6fa28dfa27e536375f7a5f7b6c5a721add519b3 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 11 Dec 2019 15:51:40 -0500 Subject: [PATCH] Delete more dead code that causes compile issues --- src/komodo_bitcoind.h | 1 - src/pow.cpp | 127 ------------------------------------------ src/pow.h | 2 - 3 files changed, 130 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index bcd2cf91a..5e46960f1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -28,7 +28,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp); int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp); -unsigned int lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); bool EnsureWalletIsAvailable(bool avoidException); extern bool fRequestShutdown; extern CScript KOMODO_EARLYTXID_SCRIPTPUB; diff --git a/src/pow.cpp b/src/pow.cpp index e402cb63f..578ee738d 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -613,133 +613,6 @@ bool DoesHashQualify(const CBlockIndex *pbindex) return true; } -// the goal is to keep POS at a solve time that is a ratio of block time units. the low resolution makes a stable solution more challenging -// and requires that the averaging window be quite long. -uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params) -{ - arith_uint256 nextTarget {0}, sumTarget {0}, bnTmp, bnLimit; - bnLimit = UintToArith256(params.posLimit); - uint32_t nProofOfStakeLimit = bnLimit.GetCompact(); - int64_t t = 0, solvetime = 0; - int64_t k = params.nLwmaPOSAjustedWeight; - int64_t N = params.nPOSAveragingWindow; - - struct solveSequence { - int64_t solveTime; - bool consecutive; - uint32_t nBits; - solveSequence() - { - consecutive = 0; - solveTime = 0; - nBits = 0; - } - }; - - // Find the first block in the averaging interval as we total the linearly weighted average - // of POS solve times - const CBlockIndex* pindexFirst = pindexLast; - - // we need to make sure we have a starting nBits reference, which is either the last POS block, or the default - // if we have had no POS block in the threshold number of blocks, we must return the default, otherwise, we'll now have - // a starting point - uint32_t nBits = nProofOfStakeLimit; - for (int64_t i = 0; i < KOMODO_NOPOS_THRESHHOLD; i++) - { - if (!pindexFirst) - return nProofOfStakeLimit; - - CBlockHeader hdr = pindexFirst->GetBlockHeader(); - - pindexFirst = pindexFirst->pprev; - } - - pindexFirst = pindexLast; - std::vector idx = std::vector(); - idx.resize(N); - - for (int64_t i = N - 1; i >= 0; i--) - { - // we measure our solve time in passing of blocks, where one bock == KOMODO_BLOCK_POSUNITS units - // consecutive blocks in either direction have their solve times exponentially multiplied or divided by power of 2 - int x; - for (x = 0; x < KOMODO_CONSECUTIVE_POS_THRESHOLD; x++) - { - pindexFirst = pindexFirst->pprev; - - if (!pindexFirst) - return nProofOfStakeLimit; - - CBlockHeader hdr = pindexFirst->GetBlockHeader(); - } - - if (x) - { - idx[i].consecutive = false; - { - int64_t lastSolveTime = 0; - idx[i].solveTime = KOMODO_BLOCK_POSUNITS; - for (int64_t j = 0; j < x; j++) - { - lastSolveTime = KOMODO_BLOCK_POSUNITS + (lastSolveTime >> 1); - idx[i].solveTime += lastSolveTime; - } - } - idx[i].nBits = nBits; - } - else - { - idx[i].consecutive = true; - idx[i].nBits = nBits; - // go forward and halve the minimum solve time for all consecutive blocks in this run, to get here, our last block is POS, - // and if there is no POS block in front of it, it gets the normal solve time of one block - uint32_t st = KOMODO_BLOCK_POSUNITS; - for (int64_t j = i; j < N; j++) - { - if (idx[j].consecutive == true) - { - idx[j].solveTime = st; - if ((j - i) >= KOMODO_CONSECUTIVE_POS_THRESHOLD) - { - // if this is real time, return zero - if (j == (N - 1)) - { - // target of 0 (virtually impossible), if we hit max consecutive POS blocks - nextTarget.SetCompact(0); - return nextTarget.GetCompact(); - } - } - st >>= 1; - } - else - break; - } - } - } - - for (int64_t i = N - 1; i >= 0; i--) - { - // weighted sum - t += idx[i].solveTime * i; - - // Target sum divided by a factor, (k N^2). - // The factor is a part of the final equation. However we divide - // here to avoid potential overflow. - bnTmp.SetCompact(idx[i].nBits); - sumTarget += bnTmp / (k * N * N); - } - - // Keep t reasonable in case strange solvetimes occurred. - if (t < N * k / 3) - t = N * k / 3; - - nextTarget = t * sumTarget; - if (nextTarget > bnLimit) - nextTarget = bnLimit; - - return nextTarget.GetCompact(); -} - bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& params) { if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) diff --git a/src/pow.h b/src/pow.h index 4946cb6e8..1de85d5cb 100644 --- a/src/pow.h +++ b/src/pow.h @@ -37,8 +37,6 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg, int64_t nLastBlockTime, int64_t nFirstBlockTime, const Consensus::Params&); -unsigned int lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params); - /** Check whether the Equihash solution in a block header is valid */ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams&);