From ba9b3220f71d317b9fd403b5774ca157f9f8743d Mon Sep 17 00:00:00 2001 From: wowario Date: Mon, 23 Apr 2018 19:43:04 +0300 Subject: [PATCH] fix signed unsigned conversion --- src/cryptonote_basic/difficulty.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_basic/difficulty.cpp b/src/cryptonote_basic/difficulty.cpp index 09798d787..b1862fc89 100644 --- a/src/cryptonote_basic/difficulty.cpp +++ b/src/cryptonote_basic/difficulty.cpp @@ -219,11 +219,11 @@ namespace cryptonote { uint64_t difficulty(0), next_difficulty(0); // Loop through N most recent blocks. N is most recently solved block. - for (int64_t i = 1; i <= N; i++) { + for (size_t i = 1; i <= N; i++) { solveTime = static_cast(timestamps[i]) - static_cast(timestamps[i - 1]); solveTime = std::min((T * 7), std::max(solveTime, (-7 * T))); difficulty = cumulative_difficulties[i] - cumulative_difficulties[i - 1]; - LWMA += solveTime * i / k; + LWMA += (int64_t)(solveTime * i) / k; sum_inverse_D += 1 / static_cast(difficulty); }