Changeset View
Changeset View
Standalone View
Standalone View
src/timedata.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | void AddTimeData(const CNetAddr &ip, int64_t nOffsetSample) { | ||||
// So we should hold off on fixing this and clean it up as part of a timing | // So we should hold off on fixing this and clean it up as part of a timing | ||||
// cleanup that strengthens it in a number of other ways. | // cleanup that strengthens it in a number of other ways. | ||||
// | // | ||||
if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1) { | if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1) { | ||||
int64_t nMedian = vTimeOffsets.median(); | int64_t nMedian = vTimeOffsets.median(); | ||||
std::vector<int64_t> vSorted = vTimeOffsets.sorted(); | std::vector<int64_t> vSorted = vTimeOffsets.sorted(); | ||||
// Only let other nodes change our time by so much | // Only let other nodes change our time by so much | ||||
if (abs64(nMedian) <= | if (abs64(nMedian) <= | ||||
std::max<int64_t>(0, | std::max<int64_t>(0, gArgs.GetArg("-maxtimeadjustment", | ||||
gArgs.GetArg("-maxtimeadjustment", | |||||
DEFAULT_MAX_TIME_ADJUSTMENT))) { | DEFAULT_MAX_TIME_ADJUSTMENT))) { | ||||
nTimeOffset = nMedian; | nTimeOffset = nMedian; | ||||
} else { | } else { | ||||
nTimeOffset = 0; | nTimeOffset = 0; | ||||
static bool fDone; | static bool fDone; | ||||
if (!fDone) { | if (!fDone) { | ||||
// If nobody has a time different than ours but within 5 minutes | // If nobody has a time different than ours but within 5 minutes | ||||
// of ours, give a warning | // of ours, give a warning | ||||
Show All 30 Lines |