diff --git a/src/pow.cpp b/src/pow.cpp index e404ca652..53add30b5 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -167,8 +167,8 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus:: int64_t N = params.nPOSAveragingWindow; struct solveSequence { + int64_t solveTime; bool consecutive; - uint32_t solveTime; uint32_t nBits; solveSequence() { @@ -186,7 +186,7 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus:: // 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 (int i = 0; i < VERUS_NOPOS_THRESHHOLD; i++) + for (int64_t i = 0; i < VERUS_NOPOS_THRESHHOLD; i++) { if (!pindexFirst) return nProofOfStakeLimit; @@ -205,7 +205,7 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus:: std::vector idx = std::vector(); idx.resize(N); - for (int i = N - 1; i >= 0; i--) + for (int64_t i = N - 1; i >= 0; i--) { // we measure our solve time in passing of blocks, where one bock == VERUS_BLOCK_POSUNITS units // consecutive blocks in either direction have their solve times exponentially multiplied or divided by power of 2 @@ -238,7 +238,7 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus:: // 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 = VERUS_BLOCK_POSUNITS; - for (int j = i; j < N; j++) + for (int64_t j = i; j < N; j++) { if (idx[j].consecutive == true) { @@ -246,7 +246,7 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus:: if ((j - i) >= VERUS_CONSECUTIVE_POS_THRESHOLD) { // if this is real time, return zero - if (i > (N - VERUS_CONSECUTIVE_POS_THRESHOLD)) + if (j == (N - 1)) { // target of 0 (virtually impossible), if we hit max consecutive POS blocks nextTarget.SetCompact(0); @@ -261,7 +261,7 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus:: } } - for (int i = N - 1; i >= 0; i--) + for (int64_t i = N - 1; i >= 0; i--) { // weighted sum t += idx[i].solveTime * i;