// Trying to get new offset sample from trusted NTP server.
int64_t nClockOffset = NtpGetTime(strTrustedUpstream) - GetTime();
- if (abs64(nClockOffset) < nMaxOffset) {
+ if (abs(nClockOffset) < nMaxOffset) {
// Everything seems right, remember new trusted offset.
printf("ThreadNtpSamples: new offset sample from %s, offset=%" PRId64 ".\n", strTrustedUpstream.c_str(), nClockOffset);
nNtpOffset = nClockOffset;
CNetAddr ip;
int64_t nClockOffset = NtpGetTime(ip) - GetTime();
- if (abs64(nClockOffset) < nMaxOffset) { // Skip the deliberately wrong timestamps
+ if (abs(nClockOffset) < nMaxOffset) { // Skip the deliberately wrong timestamps
printf("ThreadNtpSamples: new offset sample from %s, offset=%" PRId64 ".\n", ip.ToString().c_str(), nClockOffset);
vTimeOffsets.input(nClockOffset);
}
}
}
- if (GetNodesOffset() == INT_MAX && abs64(nNtpOffset) > 40 * 60)
+ if (GetNodesOffset() == INT_MAX && abs(nNtpOffset) > 40 * 60)
{
// If there is not enough node offsets data and NTP time offset is greater than 40 minutes then give a warning.
std::string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong NovaCoin will not work properly.");
int64_t GetTimeOffset()
{
// If NTP and system clock are in agreement within 40 minutes, then use NTP.
- if (abs64(nNtpOffset) < 40 * 60)
+ if (abs(nNtpOffset) < 40 * 60)
return nNtpOffset;
// If not, then choose between median peer time and system clock.
- if (abs64(nNodesOffset) < 70 * 60)
+ if (abs(nNodesOffset) < 70 * 60)
return nNodesOffset;
return 0;
printf("Added time data, samples %d, offset %+" PRId64 " (%+" PRId64 " minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);
if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
{
- int64_t nMedian = vTimeOffsets.median();
- vector<int64_t> vSorted = vTimeOffsets.sorted();
+ auto nMedian = vTimeOffsets.median();
+ auto vSorted = vTimeOffsets.sorted();
// Only let other nodes change our time by so much
- if (abs64(nMedian) < 70 * 60)
+ if (abs(nMedian) < 70 * 60)
{
nNodesOffset = nMedian;
}
bool fMatch = false;
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
- for(int64_t nOffset : vSorted)
- if (nOffset != 0 && abs64(nOffset) < 5 * 60)
+ for(auto nOffset : vSorted)
+ if (nOffset != 0 && abs(nOffset) < 5 * 60)
fMatch = true;
if (!fMatch)
return (int64_t)(d > 0 ? d + 0.5 : d - 0.5);
}
-inline int64_t abs64(int64_t n)
-{
- return (n >= 0 ? n : -n);
-}
-
inline std::string leftTrim(std::string src, char chr)
{
std::string::size_type pos = src.find_first_not_of(chr, 0);