aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-11-06 21:30:52 +0200
committerRiccardo Spagni <ric@spagni.net>2018-11-06 21:30:52 +0200
commit0991aa8964153c2412a7b24b21ebca35be80e54a (patch)
tree0c69e6c9b98bfbd08588a344da8812087081cbea /src
parentMerge pull request #4732 (diff)
parentcryptonote_core: avoid gratuitous recalculations in check_block_rate() (diff)
downloadmonero-0991aa8964153c2412a7b24b21ebca35be80e54a.tar.xz
Merge pull request #4733
b3067962 cryptonote_core: avoid gratuitous recalculations in check_block_rate() (xiphon)
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp3
1 files changed, 2 insertions, 1 deletions
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<time_t>(seconds[n]);
+ const time_t time_boundary = now - static_cast<time_t>(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)