diff --git a/src/timedata.cpp b/src/timedata.cpp index 5fc4e47..91de5ea 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 XBI_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 setKnown; + if (setKnown.size() == XBI_TIMEDATA_MAX_SAMPLES) + return; if (!setKnown.insert(ip).second) return; // Add data - static CMedianFilter vTimeOffsets(200, 0); + static CMedianFilter vTimeOffsets(XBI_TIMEDATA_MAX_SAMPLES, 0); vTimeOffsets.input(nOffsetSample); LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample / 60);