mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
p2p: Add timeout for AddrFetch peers
If AddrFetch peers don't send us addresses, disconnect them after a while.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user