diff options
author | Pavel JanÃk <Pavel@Janik.cz> | 2015-08-11 15:57:52 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-10-10 11:49:47 +0200 |
commit | 91ef4d93d4952759a6c766fd94eaf2c1df78c372 (patch) | |
tree | 7bbbcefc67b0e28dd8b570a3070bf69aac71d387 /src/timedata.cpp | |
parent | f2778e0ce6581f68382a4812ef847d387b35f2a0 (diff) |
Do not store more than 200 timedata samples.
Github-Pull: #6797
Rebased-From: 8be371db340b03dc03142c1bb3390fdfc84f56b4
Diffstat (limited to 'src/timedata.cpp')
-rw-r--r-- | src/timedata.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/timedata.cpp b/src/timedata.cpp index 59f7778db1..61a113513d 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -40,6 +40,8 @@ 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 nTime) { int64_t nOffsetSample = nTime - GetTime(); @@ -47,11 +49,13 @@ void AddTimeData(const CNetAddr& ip, int64_t nTime) LOCK(cs_nTimeOffset); // Ignore duplicates static set<CNetAddr> setKnown; + if (setKnown.size() == BITCOIN_TIMEDATA_MAX_SAMPLES) + return; if (!setKnown.insert(ip).second) return; // Add data - static CMedianFilter<int64_t> vTimeOffsets(200,0); + static CMedianFilter<int64_t> 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); |