diff options
| author | Wladimir J. van der Laan <[email protected]> | 2015-08-20 17:12:35 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2015-08-20 17:13:52 +0200 |
| commit | e128464bc5ae7e81fc84530b829343b03781f5a6 (patch) | |
| tree | db48107f0f346db066cef454b04665c5968421d6 /src | |
| parent | Merge pull request #6556 (diff) | |
| parent | Do not store more than 200 timedata samples. (diff) | |
| download | discoin-e128464bc5ae7e81fc84530b829343b03781f5a6.tar.xz discoin-e128464bc5ae7e81fc84530b829343b03781f5a6.zip | |
Merge pull request #6545
8be371d Do not store more than 200 timedata samples. (Pavel JanÃk)
Diffstat (limited to 'src')
| -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 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<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); |