Skip to content

Commit 00001e5

Browse files
author
MarcoFalke
committed
Remove redundant nTime checks
nTime is always initialized on deserialization or default-initialized with TIME_INIT, so special casing 0 does not make sense.
1 parent bbf2a25 commit 00001e5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/addrman.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ bool AddrInfo::IsTerrible(int64_t nNow) const
7272
if (nTime > nNow + 10 * 60) // came in a flying DeLorean
7373
return true;
7474

75-
if (nTime == 0 || nNow - nTime > ADDRMAN_HORIZON_DAYS * 24 * 60 * 60) // not seen in recent history
75+
if (nNow - nTime > ADDRMAN_HORIZON_DAYS * 24 * 60 * 60) { // not seen in recent history
7676
return true;
77+
}
7778

7879
if (nLastSuccess == 0 && nAttempts >= ADDRMAN_RETRIES) // tried N times and never a success
7980
return true;
@@ -557,15 +558,17 @@ bool AddrManImpl::AddSingle(const CAddress& addr, const CNetAddr& source, int64_
557558
// periodically update nTime
558559
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
559560
int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
560-
if (addr.nTime && (!pinfo->nTime || pinfo->nTime < addr.nTime - nUpdateInterval - nTimePenalty))
561+
if (pinfo->nTime < addr.nTime - nUpdateInterval - nTimePenalty) {
561562
pinfo->nTime = std::max((int64_t)0, addr.nTime - nTimePenalty);
563+
}
562564

563565
// add services
564566
pinfo->nServices = ServiceFlags(pinfo->nServices | addr.nServices);
565567

566568
// do not update if no new information is present
567-
if (!addr.nTime || (pinfo->nTime && addr.nTime <= pinfo->nTime))
569+
if (addr.nTime <= pinfo->nTime) {
568570
return false;
571+
}
569572

570573
// do not update if the entry was already in the "tried" table
571574
if (pinfo->fInTried)

0 commit comments

Comments
 (0)