Skip to content

Commit d5b78aa

Browse files
committed
netsync: don't add peer if we're not current and the peer is not a sync
candidate Since we can use all the peers we could get for ibd, don't add peers that are not sync candidates when we're still not current.
1 parent 6bae737 commit d5b78aa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

netsync/manager.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,17 @@ func (sm *SyncManager) handleNewPeerMsg(peer *peerpkg.Peer) {
590590
return
591591
}
592592

593-
log.Infof("New valid peer %s (%s)", peer, peer.UserAgent())
594-
595593
// Initialize the peer state.
596594
isSyncCandidate := sm.isSyncCandidate(peer)
595+
if !sm.current() && !isSyncCandidate {
596+
log.Infof("New peer %s (%s) is not a valid sync candidate -- disconnecting",
597+
peer, peer.UserAgent())
598+
peer.Disconnect()
599+
return
600+
}
601+
602+
log.Infof("New valid peer %s (%s)", peer, peer.UserAgent())
603+
597604
sm.peerStates[peer] = &peerSyncState{
598605
syncCandidate: isSyncCandidate,
599606
requestedTxns: make(map[chainhash.Hash]struct{}),

0 commit comments

Comments
 (0)