From b3067962faf5b2863fc9e72a603a65bd2e5aa55f Mon Sep 17 00:00:00 2001 From: xiphon Date: Mon, 5 Nov 2018 00:13:51 +0000 Subject: [PATCH] cryptonote_core: avoid gratuitous recalculations in check_block_rate() --- src/cryptonote_core/cryptonote_core.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 4b806c282..c405c996a 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -1716,7 +1716,8 @@ namespace cryptonote for (size_t n = 0; n < sizeof(seconds)/sizeof(seconds[0]); ++n) { unsigned int b = 0; - for (time_t ts: timestamps) b += ts >= now - static_cast(seconds[n]); + const time_t time_boundary = now - static_cast(seconds[n]); + for (time_t ts: timestamps) b += ts >= time_boundary; const double p = probability(b, seconds[n] / DIFFICULTY_TARGET_V2); MDEBUG("blocks in the last " << seconds[n] / 60 << " minutes: " << b << " (probability " << p << ")"); if (p < threshold)