From 649f5d9c1100bb3cbace724900f035939df5ea11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Jan=C3=ADk?= Date: Tue, 11 Aug 2015 15:57:52 +0200 Subject: [PATCH] Do not store more than 200 timedata samples. Github-Pull: #6545 Rebased-From: 8be371db340b03dc03142c1bb3390fdfc84f56b4 --- src/timedata.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/timedata.cpp b/src/timedata.cpp index c3e9c75f6..a14d69c11 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -40,16 +40,20 @@ static int64_t abs64(int64_t n) return (n >= 0 ? n : -n); } +#define BITCOIN_TIMEDATA_MAX_SAMPLES 200 + void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) { LOCK(cs_nTimeOffset); // Ignore duplicates static set setKnown; + if (setKnown.size() == BITCOIN_TIMEDATA_MAX_SAMPLES) + return; if (!setKnown.insert(ip).second) return; // Add data - static CMedianFilter vTimeOffsets(200,0); + static CMedianFilter vTimeOffsets(BITCOIN_TIMEDATA_MAX_SAMPLES, 0); vTimeOffsets.input(nOffsetSample); LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);