 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
5 #if defined(HAVE_CONFIG_H)
40 #define BITCOIN_TIMEDATA_MAX_SAMPLES 200
46 static std::set<CNetAddr> setKnown;
49 if (!setKnown.insert(
ip).second)
54 vTimeOffsets.
input(nOffsetSample);
55 LogPrint(
BCLog::NET,
"added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.
size(), nOffsetSample, nOffsetSample / 60);
74 if (vTimeOffsets.
size() >= 5 && vTimeOffsets.
size() % 2 == 1) {
75 int64_t nMedian = vTimeOffsets.
median();
76 std::vector<int64_t> vSorted = vTimeOffsets.
sorted();
79 if (nMedian >= -max_adjustment && nMedian <= max_adjustment) {
80 nTimeOffset = nMedian;
88 for (
const int64_t nOffset : vSorted) {
89 if (nOffset != 0 && nOffset > -5 * 60 && nOffset < 5 * 60) fMatch =
true;
102 std::string log_message{
"time data samples: "};
103 for (
const int64_t n : vSorted) {
106 log_message +=
strprintf(
"| median offset = %+d (%+d minutes)", nTimeOffset, nTimeOffset / 60);
bilingual_str _(const char *psz)
Translation function.
static const int64_t DEFAULT_MAX_TIME_ADJUSTMENT
CClientUIInterface uiInterface
int64_t GetTime()
DEPRECATED Use either GetTimeSeconds (not mockable) or GetTime<T> (mockable)
static Mutex g_timeoffset_mutex
static int64_t nTimeOffset GUARDED_BY(g_timeoffset_mutex)=0
static CService ip(uint32_t i)
void SetMiscWarning(const bilingual_str &warning)
#define LogPrint(category,...)
void AddTimeData(const CNetAddr &ip, int64_t nOffsetSample)
int64_t GetAdjustedTime()
static bool LogAcceptCategory(BCLog::LogFlags category)
Return true if log accepts specified category.
#define BITCOIN_TIMEDATA_MAX_SAMPLES
int64_t GetTimeOffset()
"Never go to sea with two chronometers; take one or three." Our three time sources are:
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.