5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
39#define BITCOIN_TIMEDATA_MAX_SAMPLES 200
58 "added time data, samples %d, offset %+d (%+d minutes)\n",
83 int64_t max_adjustment =
86 if (nMedian >= -max_adjustment && nMedian <= max_adjustment) {
87 nTimeOffset = nMedian;
95 for (
const int64_t nOffset : vSorted) {
96 if (nOffset != 0 && nOffset > -5 * 60 && nOffset < 5 * 60) {
104 strprintf(
_(
"Please check that your computer's date "
105 "and time are correct! If your clock is "
106 "wrong, %s will not work properly."),
116 for (
const int64_t n : vSorted) {
122 nTimeOffset, nTimeOffset / 60);
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
Different type to mark Mutex at global scope.
#define LogPrint(category,...)
#define LogPrintToBeContinued
static bool LogAcceptCategory(BCLog::LogFlags category, BCLog::Level level)
Return true if log accepts specified category, at the specified level.
static time_point now() noexcept
Return current system time or mocked time, if set.
std::chrono::time_point< NodeClock > time_point
int64_t GetTimeOffset()
"Never go to sea with two chronometers; take one or three." Our three time sources are:
void TestOnlyResetTimeData()
Reset the internal state of GetTimeOffset(), GetAdjustedTime() and AddTimeData().
static GlobalMutex g_timeoffset_mutex
#define BITCOIN_TIMEDATA_MAX_SAMPLES
NodeClock::time_point GetAdjustedTime()
static std::set< CNetAddr > g_sources
void AddTimeData(const CNetAddr &ip, int64_t nOffsetSample)
static int64_t nTimeOffset GUARDED_BY(g_timeoffset_mutex)=0
static CMedianFilter< int64_t > g_time_offsets(BITCOIN_TIMEDATA_MAX_SAMPLES, 0)
static bool g_warning_emitted
static const int64_t DEFAULT_MAX_TIME_ADJUSTMENT
bilingual_str _(const char *psz)
Translation function.
CClientUIInterface uiInterface
void SetMiscWarning(const bilingual_str &warning)