We have constants (commit e1fc548) 263/head
authorsvost <ya.nowa@yandex.ru>
Sat, 16 Jan 2016 13:52:49 +0000 (16:52 +0300)
committersvost <ya.nowa@yandex.ru>
Sat, 16 Jan 2016 13:52:49 +0000 (16:52 +0300)
src/addrman.cpp
src/checkpoints.h
src/kernelrecord.cpp
src/ntp.cpp

index 6676f62..ed17c39 100644 (file)
@@ -43,13 +43,13 @@ bool CAddrInfo::IsTerrible(int64_t nNow) const
     if (nTime > nNow + 10*60) // came in a flying DeLorean
         return true;
 
-    if (nTime==0 || nNow-nTime > ADDRMAN_HORIZON_DAYS*86400) // not seen in over a month
+    if (nTime==0 || nNow-nTime > ADDRMAN_HORIZON_DAYS*nOneDay) // not seen in over a month
         return true;
 
     if (nLastSuccess==0 && nAttempts>=ADDRMAN_RETRIES) // tried three times and never a success
         return true;
 
-    if (nNow-nLastSuccess > ADDRMAN_MIN_FAIL_DAYS*86400 && nAttempts>=ADDRMAN_MAX_FAILURES) // 10 successive failures in the last week
+    if (nNow-nLastSuccess > ADDRMAN_MIN_FAIL_DAYS*nOneDay && nAttempts>=ADDRMAN_MAX_FAILURES) // 10 successive failures in the last week
         return true;
 
     return false;
index 135838d..347b2d0 100644 (file)
@@ -8,7 +8,8 @@
 #include "util.h"
 #include "net.h"
 
-#define CHECKPOINT_MAX_SPAN (60 * 60) // max 1 hour before latest block
+// max 1 hour before latest block
+static const int64_t CHECKPOINT_MAX_SPAN = nOneHour;
 
 #ifdef WIN32
 #undef STRICT
index bf05268..a9a2e8e 100644 (file)
@@ -47,7 +47,7 @@ vector<KernelRecord> KernelRecord::decomposeOutput(const CWallet *wallet, const
                 CTxDestination address;
                 std::string addrStr;
 
-                uint64_t coinAge = max( (txOut.nValue * nDayWeight) / (COIN * 86400), (int64_t)0);
+                uint64_t coinAge = max( (txOut.nValue * nDayWeight) / (COIN * nOneDay), 0LL);
 
                 if (ExtractDestination(txOut.scriptPubKey, address))
                 {
@@ -75,7 +75,7 @@ std::string KernelRecord::getTxID()
 
 int64_t KernelRecord::getAge() const
 {
-    return (GetAdjustedTime() - nTime) / 86400;
+    return (GetAdjustedTime() - nTime) / nOneDay;
 }
 
 uint64_t KernelRecord::getCoinDay() const
@@ -84,7 +84,7 @@ uint64_t KernelRecord::getCoinDay() const
     if( nWeight <  0)
         return 0;
     nWeight = min(nWeight, (int64_t)nStakeMaxAge);
-    uint64_t coinAge = (nValue * nWeight ) / (COIN * 86400);
+    uint64_t coinAge = (nValue * nWeight ) / (COIN * nOneDay);
     return coinAge;
 }
 
@@ -94,7 +94,7 @@ int64_t KernelRecord::getPoSReward(int nBits, int minutes)
     int64_t nWeight = GetAdjustedTime() - nTime + minutes * 60;
     if( nWeight <  nStakeMinAge)
         return 0;
-    uint64_t coinAge = (nValue * nWeight ) / (COIN * 86400);
+    uint64_t coinAge = (nValue * nWeight ) / (COIN * nOneDay);
     PoSReward = GetProofOfStakeReward(coinAge, nBits, GetAdjustedTime() + minutes * 60);
     return PoSReward;
 }
@@ -107,7 +107,7 @@ double KernelRecord::getProbToMintStake(double difficulty, int timeOffset) const
     //uint64_t coinAge = max(nValue * dayWeight / COIN, (int64_t)0);
     //return target * coinAge / pow(static_cast<double>(2), 256);
     int64_t Weight = (min((GetAdjustedTime() - nTime) + timeOffset, (int64_t)(nStakeMinAge+nStakeMaxAge)) - nStakeMinAge);
-    uint64_t coinAge = max(nValue * Weight / (COIN * 86400), (int64_t)0);
+    uint64_t coinAge = max(nValue * Weight / (COIN * nOneDay), 0LL);
     return coinAge / (pow(static_cast<double>(2),32) * difficulty);
 }
 
@@ -124,13 +124,13 @@ double KernelRecord::getProbToMintWithinNMinutes(double difficulty, int minutes)
         // Probabilities for the first d days
         for(i = 0; i < d; i++)
         {
-            timeOffset = i * 86400;
-            p = pow(1 - getProbToMintStake(difficulty, timeOffset), 86400);
+            timeOffset = i * nOneDay;
+            p = pow(1 - getProbToMintStake(difficulty, timeOffset), nOneDay);
             prob *= p;
         }
 
         // Probability for the m minutes of the last day
-        timeOffset = d * 86400;
+        timeOffset = d * nOneDay;
         p = pow(1 - getProbToMintStake(difficulty, timeOffset), 60 * m);
         prob *= p;
 
index 527a02c..d66f3bb 100644 (file)
@@ -445,7 +445,7 @@ int64_t GetNtpOffset() {
 }
 
 void ThreadNtpSamples(void* parg) {
-    const int64_t nMaxOffset = 86400; // Not a real limit, just sanity threshold.
+    const int64_t nMaxOffset = nOneDay; // Not a real limit, just sanity threshold.
 
     printf("Trying to find NTP server at localhost...\n");