p2p: Add timeout for AddrFetch peers

If AddrFetch peers don't send us addresses, disconnect them after
a while.
This commit is contained in:
Martin Zumsande 2021-05-29 23:58:37 +02:00
parent b6c5d1e450
commit 533500d907

View file

@ -4364,6 +4364,12 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
const auto current_time = GetTime<std::chrono::microseconds>();
if (pto->IsAddrFetchConn() && current_time - std::chrono::seconds(pto->nTimeConnected) > 10 * AVG_ADDRESS_BROADCAST_INTERVAL) {
LogPrint(BCLog::NET, "addrfetch connection timeout; disconnecting peer=%d\n", pto->GetId());
pto->fDisconnect = true;
return true;
}
MaybeSendPing(*pto, *peer, current_time);
// MaybeSendPing may have marked peer for disconnection