mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03: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:
parent
b6c5d1e450
commit
533500d907
1 changed files with 6 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue