5 #if defined(HAVE_CONFIG_H) 19 static int64_t nTimeOffset
GUARDED_BY(g_timeoffset_mutex) = 0;
30 LOCK(g_timeoffset_mutex);
39 #define BITCOIN_TIMEDATA_MAX_SAMPLES 200 43 LOCK(g_timeoffset_mutex);
45 static std::set<CNetAddr> setKnown;
48 if (!setKnown.insert(ip).second)
53 vTimeOffsets.
input(nOffsetSample);
54 LogPrint(
BCLog::NET,
"added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.
size(), nOffsetSample, nOffsetSample / 60);
73 if (vTimeOffsets.
size() >= 5 && vTimeOffsets.
size() % 2 == 1) {
74 int64_t nMedian = vTimeOffsets.
median();
75 std::vector<int64_t> vSorted = vTimeOffsets.
sorted();
78 if (nMedian >= -max_adjustment && nMedian <= max_adjustment) {
79 nTimeOffset = nMedian;
87 for (
const int64_t nOffset : vSorted) {
88 if (nOffset != 0 && nOffset > -5 * 60 && nOffset < 5 * 60) fMatch =
true;
101 for (
const int64_t n : vSorted) {
105 LogPrint(
BCLog::NET,
"nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset / 60);
#define LogPrint(category,...)
#define BITCOIN_TIMEDATA_MAX_SAMPLES
void SetMiscWarning(const bilingual_str &warning)
int64_t GetTimeOffset()
"Never go to sea with two chronometers; take one or three." Our three time sources are: ...
static int64_t nTimeOffset GUARDED_BY(g_timeoffset_mutex)=0
bilingual_str _(const char *psz)
Translation function.
static bool LogAcceptCategory(BCLog::LogFlags category)
Return true if log accepts specified category.
static Mutex g_timeoffset_mutex
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
int64_t GetAdjustedTime()
CClientUIInterface uiInterface
void AddTimeData(const CNetAddr &ip, int64_t nOffsetSample)
int64_t GetTime()
Return system time (or mocked time, if set)
static const int64_t DEFAULT_MAX_TIME_ADJUSTMENT