diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-04-11 13:37:05 +0200 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-06-08 09:17:39 +0200 |
commit | 00001e57fe74c061aa9cbc72b07252335cb566e0 (patch) | |
tree | e9e7dd072325073de768a3e2aa95900e140f0486 /src | |
parent | bbf2a2504459ae70f1d5dc356f9d25f4ccfafdc8 (diff) | |
download | bitcoin-00001e57fe74c061aa9cbc72b07252335cb566e0.tar.xz |
Remove redundant nTime checks
nTime is always initialized on deserialization or default-initialized
with TIME_INIT, so special casing 0 does not make sense.
Diffstat (limited to 'src')
-rw-r--r-- | src/addrman.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp index ed823eeb05..678396993b 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -72,8 +72,9 @@ bool AddrInfo::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 * 24 * 60 * 60) // not seen in recent history + if (nNow - nTime > ADDRMAN_HORIZON_DAYS * 24 * 60 * 60) { // not seen in recent history return true; + } if (nLastSuccess == 0 && nAttempts >= ADDRMAN_RETRIES) // tried N times and never a success return true; @@ -557,15 +558,17 @@ bool AddrManImpl::AddSingle(const CAddress& addr, const CNetAddr& source, int64_ // periodically update nTime bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60); int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60); - if (addr.nTime && (!pinfo->nTime || pinfo->nTime < addr.nTime - nUpdateInterval - nTimePenalty)) + if (pinfo->nTime < addr.nTime - nUpdateInterval - nTimePenalty) { pinfo->nTime = std::max((int64_t)0, addr.nTime - nTimePenalty); + } // add services pinfo->nServices = ServiceFlags(pinfo->nServices | addr.nServices); // do not update if no new information is present - if (!addr.nTime || (pinfo->nTime && addr.nTime <= pinfo->nTime)) + if (addr.nTime <= pinfo->nTime) { return false; + } // do not update if the entry was already in the "tried" table if (pinfo->fInTried) |