Browse Source

Merge pull request #6545

8be371d Do not store more than 200 timedata samples. (Pavel Janík)
0.13
Wladimir J. van der Laan 9 years ago
parent
commit
e128464bc5
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 6
      src/timedata.cpp

6
src/timedata.cpp

@ -40,16 +40,20 @@ static int64_t abs64(int64_t n)
return (n >= 0 ? n : -n); return (n >= 0 ? n : -n);
} }
#define BITCOIN_TIMEDATA_MAX_SAMPLES 200
void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
{ {
LOCK(cs_nTimeOffset); LOCK(cs_nTimeOffset);
// Ignore duplicates // Ignore duplicates
static set<CNetAddr> setKnown; static set<CNetAddr> setKnown;
if (setKnown.size() == BITCOIN_TIMEDATA_MAX_SAMPLES)
return;
if (!setKnown.insert(ip).second) if (!setKnown.insert(ip).second)
return; return;
// Add data // Add data
static CMedianFilter<int64_t> vTimeOffsets(200,0); static CMedianFilter<int64_t> vTimeOffsets(BITCOIN_TIMEDATA_MAX_SAMPLES, 0);
vTimeOffsets.input(nOffsetSample); vTimeOffsets.input(nOffsetSample);
LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);

Loading…
Cancel
Save