mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
p2p: don't disconnect addnode peers for slow initial-headers-sync
This commit is contained in:
parent
3463a7f481
commit
64b956f422
1 changed files with 4 additions and 3 deletions
|
@ -5826,17 +5826,18 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
|||
// Detect whether this is a stalling initial-headers-sync peer
|
||||
if (m_chainman.m_best_header->Time() <= NodeClock::now() - 24h) {
|
||||
if (current_time > peer->m_headers_sync_timeout && nSyncStarted == 1 && (m_num_preferred_download_peers - state.fPreferredDownload >= 1)) {
|
||||
// Disconnect a peer (without NetPermissionFlags::NoBan permission) if it is our only sync peer,
|
||||
// Disconnect a peer (if it is neither an addnode peer, nor has
|
||||
// NetPermissionFlags::NoBan permission) if it is our only sync peer
|
||||
// and we have others we could be using instead.
|
||||
// Note: If all our peers are inbound, then we won't
|
||||
// disconnect our sync peer for stalling; we have bigger
|
||||
// problems if we can't get any outbound peers.
|
||||
if (!pto->HasPermission(NetPermissionFlags::NoBan)) {
|
||||
if (!pto->IsManualConn() && !pto->HasPermission(NetPermissionFlags::NoBan)) {
|
||||
LogInfo("Timeout downloading headers, %s\n", pto->DisconnectMsg(fLogIPs));
|
||||
pto->fDisconnect = true;
|
||||
return true;
|
||||
} else {
|
||||
LogInfo("Timeout downloading headers from noban peer, not %s\n", pto->DisconnectMsg(fLogIPs));
|
||||
LogInfo("Timeout downloading headers from %s peer, not %s\n", pto->IsManualConn() ? "addnode" : "noban", pto->DisconnectMsg(fLogIPs));
|
||||
// Reset the headers sync state so that we have a
|
||||
// chance to try downloading from a different peer.
|
||||
// Note: this will also result in at least one more
|
||||
|
|
Loading…
Add table
Reference in a new issue