From ad42655e7a1f22e2a75e14ad73776367229ed081 Mon Sep 17 00:00:00 2001 From: svost Date: Wed, 7 Oct 2015 17:36:05 +0300 Subject: [PATCH] We have constants (commit e1fc548) --- src/init.cpp | 2 +- src/main.cpp | 14 +++++++------- src/main.h | 2 +- src/net.cpp | 3 +-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 4b71dec..36837ad 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -380,7 +380,7 @@ bool AppInit2() // Ping and address broadcast intervals nPingInterval = max(10 * 60, GetArg("-keepalive", 30 * 60)); - nBroadcastInterval = max(6 * 60 * 60, GetArg("-addrsetlifetime", nOneDay)); + nBroadcastInterval = max(6 * nOneHour, GetArg("-addrsetlifetime", nOneDay)); CheckpointsMode = Checkpoints::STRICT; std::string strCpMode = GetArg("-cppolicy", "strict"); diff --git a/src/main.cpp b/src/main.cpp index d96af0a..9ff24e4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,10 +42,10 @@ uint256 nPoWBase = uint256("0x00000000ffff00000000000000000000000000000000000000 CBigNum bnProofOfWorkLimitTestNet(~uint256(0) >> 16); -unsigned int nStakeMinAge = 60 * 60 * 24 * 30; // 30 days as zero time weight -unsigned int nStakeMaxAge = 60 * 60 * 24 * 90; // 90 days as full weight +unsigned int nStakeMinAge = 30 * nOneDay; // 30 days as zero time weight +unsigned int nStakeMaxAge = 90 * nOneDay; // 90 days as full weight unsigned int nStakeTargetSpacing = 10 * 60; // 10-minute stakes spacing -unsigned int nModifierInterval = 6 * 60 * 60; // time to elapse before new modifier is computed +unsigned int nModifierInterval = 6 * nOneHour; // time to elapse before new modifier is computed int nCoinbaseMaturity = 500; @@ -2736,7 +2736,7 @@ bool LoadBlockIndex(bool fAllowNew) pchMessageStart[3] = 0xef; bnProofOfWorkLimit = bnProofOfWorkLimitTestNet; // 16 bits PoW target limit for testnet - nStakeMinAge = 2 * 60 * 60; // test net min age is 2 hours + nStakeMinAge = 2 * nOneHour; // test net min age is 2 hours nModifierInterval = 20 * 60; // test modifier interval is 20 minutes nCoinbaseMaturity = 10; // test maturity is 10 blocks nStakeTargetSpacing = 5 * 60; // test block spacing is 5 minutes @@ -3018,7 +3018,7 @@ string GetWarnings(string strFor) // if detected unmet upgrade requirement enter safe mode // Note: Modifier upgrade requires blockchain redownload if past protocol switch - if (IsFixedModifierInterval(nModifierUpgradeTime + 60*60*24)) // 1 day margin + if (IsFixedModifierInterval(nModifierUpgradeTime + nOneDay)) // 1 day margin { nPriority = 5000; strStatusBar = strRPC = "WARNING: Blockchain redownload required approaching or past v.0.4.4.6u4 upgrade deadline."; @@ -3295,7 +3295,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (hashSalt == 0) hashSalt = GetRandHash(); uint64_t hashAddr = addr.GetHash(); - uint256 hashRand = hashSalt ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/(24*60*60)); + uint256 hashRand = hashSalt ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/nOneDay); hashRand = Hash(BEGIN(hashRand), END(hashRand)); multimap mapMix; BOOST_FOREACH(CNode* pnode, vNodes) @@ -3317,7 +3317,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (fReachable) vAddrOk.push_back(addr); } - addrman.Add(vAddrOk, pfrom->addr, 2 * 60 * 60); + addrman.Add(vAddrOk, pfrom->addr, 2 * nOneHour); if (vAddr.size() < 1000) pfrom->fGetAddr = false; if (pfrom->fOneShot) diff --git a/src/main.h b/src/main.h index abcc1aa..4992041 100644 --- a/src/main.h +++ b/src/main.h @@ -1452,7 +1452,7 @@ public: uint256 GetBlockHash() const { - if (fUseFastIndex && (nTime < GetAdjustedTime() - 24 * 60 * 60) && blockHash != 0) + if (fUseFastIndex && (nTime < GetAdjustedTime() - nOneDay) && blockHash != 0) return blockHash; CBlock block; diff --git a/src/net.cpp b/src/net.cpp index add7c91..aa2d768 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -547,7 +547,7 @@ bool CNode::Misbehaving(int howmuch) nMisbehavior += howmuch; if (nMisbehavior >= GetArgInt("-banscore", 100)) { - int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban + int64_t banTime = GetTime()+GetArg("-bantime", nOneDay); // Default 24-hour ban printf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior); { LOCK(cs_setBanned); @@ -1154,7 +1154,6 @@ void ThreadDNSAddressSeed2(void* parg) { BOOST_FOREACH(CNetAddr& ip, vaddr) { - int nOneDay = 24*3600; CAddress addr = CAddress(CService(ip, GetDefaultPort())); addr.nTime = GetTime() - 3*nOneDay - GetRand(4*nOneDay); // use a random age between 3 and 7 days old vAdd.push_back(addr); -- 1.7.1