abs64 isn't needed anymore, since abs has the overload for int64_t.
authorCryptoManiac <balthazar@yandex.ru>
Sun, 10 Apr 2016 12:30:21 +0000 (15:30 +0300)
committerCryptoManiac <balthazar@yandex.ru>
Sun, 10 Apr 2016 12:30:21 +0000 (15:30 +0300)
src/ntp.cpp
src/util.cpp
src/util.h

index 64fd46c..d05cfa5 100644 (file)
@@ -470,7 +470,7 @@ void ThreadNtpSamples(void* parg) {
             // 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;
@@ -495,7 +495,7 @@ void ThreadNtpSamples(void* parg) {
                 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);
                 }
@@ -514,7 +514,7 @@ void ThreadNtpSamples(void* parg) {
             }
         }
 
-        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.");
index b1a7f79..13ddce4 100644 (file)
@@ -1301,11 +1301,11 @@ static int64_t nNodesOffset = INT64_MAX;
 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;
@@ -1335,10 +1335,10 @@ void AddTimeData(const CNetAddr& ip, int64_t nTime)
     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;
         }
@@ -1352,8 +1352,8 @@ void AddTimeData(const CNetAddr& ip, int64_t nTime)
                 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)
index c6b5dea..507c54d 100644 (file)
@@ -317,11 +317,6 @@ inline int64_t roundint64(double d)
     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);