5 #if defined(HAVE_CONFIG_H) 20 static int64_t nTimeOffset = 0;
40 static int64_t abs64(int64_t n)
42 return (n >= 0 ? n : -n);
45 #define FABCOIN_TIMEDATA_MAX_SAMPLES 200 51 static std::set<CNetAddr> setKnown;
54 if (!setKnown.insert(ip).second)
59 vTimeOffsets.
input(nOffsetSample);
60 LogPrint(
BCLog::NET,
"added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.
size(), nOffsetSample, nOffsetSample/60);
79 if (vTimeOffsets.
size() >= 5 && vTimeOffsets.
size() % 2 == 1)
81 int64_t nMedian = vTimeOffsets.
median();
82 std::vector<int64_t> vSorted = vTimeOffsets.
sorted();
84 if (abs64(nMedian) <= std::max<int64_t>(0,
gArgs.
GetArg(
"-maxtimeadjustment", DEFAULT_MAX_TIME_ADJUSTMENT)))
86 nTimeOffset = nMedian;
97 for (int64_t nOffset : vSorted)
98 if (nOffset != 0 && abs64(nOffset) < 5 * 60)
104 std::string strMessage =
strprintf(
_(
"Please check that your computer's date and time are correct! If your clock is wrong, %s will not work properly."),
_(
PACKAGE_NAME));
112 for (int64_t n : vSorted) {
117 LogPrint(
BCLog::NET,
"nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60);
int64_t GetTimeOffset()
"Never go to sea with two chronometers; take one or three." Our three time sources are: ...
#define FABCOIN_TIMEDATA_MAX_SAMPLES
#define LogPrint(category,...)
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
int64_t GetAdjustedTime()
void SetMiscWarning(const std::string &strWarning)
boost::signals2::signal< bool(const std::string &message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeMessageBox
Show message box.
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
CClientUIInterface uiInterface
void AddTimeData(const CNetAddr &ip, int64_t nOffsetSample)
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
Wrapped boost mutex: supports recursive locking, but no waiting TODO: We should move away from using ...