mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Remove redundant nTime checks
nTime is always initialized on deserialization or default-initialized with TIME_INIT, so special casing 0 does not make sense.
This commit is contained in:
@@ -72,8 +72,9 @@ bool AddrInfo::IsTerrible(int64_t nNow) const
|
|||||||
if (nTime > nNow + 10 * 60) // came in a flying DeLorean
|
if (nTime > nNow + 10 * 60) // came in a flying DeLorean
|
||||||
return true;
|
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;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (nLastSuccess == 0 && nAttempts >= ADDRMAN_RETRIES) // tried N times and never a success
|
if (nLastSuccess == 0 && nAttempts >= ADDRMAN_RETRIES) // tried N times and never a success
|
||||||
return true;
|
return true;
|
||||||
@@ -557,15 +558,17 @@ bool AddrManImpl::AddSingle(const CAddress& addr, const CNetAddr& source, int64_
|
|||||||
// periodically update nTime
|
// periodically update nTime
|
||||||
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
|
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
|
||||||
int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 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);
|
pinfo->nTime = std::max((int64_t)0, addr.nTime - nTimePenalty);
|
||||||
|
}
|
||||||
|
|
||||||
// add services
|
// add services
|
||||||
pinfo->nServices = ServiceFlags(pinfo->nServices | addr.nServices);
|
pinfo->nServices = ServiceFlags(pinfo->nServices | addr.nServices);
|
||||||
|
|
||||||
// do not update if no new information is present
|
// 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;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// do not update if the entry was already in the "tried" table
|
// do not update if the entry was already in the "tried" table
|
||||||
if (pinfo->fInTried)
|
if (pinfo->fInTried)
|
||||||
|
|||||||
Reference in New Issue
Block a user