Skip to content

Commit e128464

Browse files
committed
Merge pull request #6545
8be371d Do not store more than 200 timedata samples. (Pavel Janík)
2 parents 70ec975 + 8be371d commit e128464

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/timedata.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,20 @@ static int64_t abs64(int64_t n)
4040
return (n >= 0 ? n : -n);
4141
}
4242

43+
#define BITCOIN_TIMEDATA_MAX_SAMPLES 200
44+
4345
void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
4446
{
4547
LOCK(cs_nTimeOffset);
4648
// Ignore duplicates
4749
static set<CNetAddr> setKnown;
50+
if (setKnown.size() == BITCOIN_TIMEDATA_MAX_SAMPLES)
51+
return;
4852
if (!setKnown.insert(ip).second)
4953
return;
5054

5155
// Add data
52-
static CMedianFilter<int64_t> vTimeOffsets(200,0);
56+
static CMedianFilter<int64_t> vTimeOffsets(BITCOIN_TIMEDATA_MAX_SAMPLES, 0);
5357
vTimeOffsets.input(nOffsetSample);
5458
LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);
5559

0 commit comments

Comments
 (0)