Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 2,281 Lines • ▼ Show 20 Lines | if (strCommand == NetMsgType::VERSION) { | ||||
LogPrint(BCLog::NET, | LogPrint(BCLog::NET, | ||||
"receive version message: [%s] %s: version %d, blocks=%d, " | "receive version message: [%s] %s: version %d, blocks=%d, " | ||||
"us=%s, peer=%d%s\n", | "us=%s, peer=%d%s\n", | ||||
pfrom->addr.ToString(), cleanSubVer, pfrom->nVersion, | pfrom->addr.ToString(), cleanSubVer, pfrom->nVersion, | ||||
pfrom->nStartingHeight, addrMe.ToString(), pfrom->GetId(), | pfrom->nStartingHeight, addrMe.ToString(), pfrom->GetId(), | ||||
remoteAddr); | remoteAddr); | ||||
int64_t nTimeOffset = nTime - GetTime(); | // Ignore time offsets that are improbable (before the Genesis block) | ||||
// and may underflow the nTimeOffset calculation. | |||||
int64_t currentTime = GetTime(); | |||||
if (nTime >= int64_t(chainparams.GenesisBlock().nTime)) { | |||||
int64_t nTimeOffset = nTime - currentTime; | |||||
pfrom->nTimeOffset = nTimeOffset; | pfrom->nTimeOffset = nTimeOffset; | ||||
AddTimeData(pfrom->addr, nTimeOffset); | AddTimeData(pfrom->addr, nTimeOffset); | ||||
} else { | |||||
Misbehaving(pfrom, 20, | |||||
"Ignoring invalid timestamp in version message"); | |||||
} | |||||
// Feeler connections exist only to verify if address is online. | // Feeler connections exist only to verify if address is online. | ||||
if (pfrom->fFeeler) { | if (pfrom->fFeeler) { | ||||
assert(pfrom->fInbound == false); | assert(pfrom->fInbound == false); | ||||
pfrom->fDisconnect = true; | pfrom->fDisconnect = true; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,557 Lines • Show Last 20 Lines |