code: func (sm *SyncManager) handleNewPeerMsg(peer *peerpkg.Peer) {
  	// Ignore if in the process of shutting down.
  	if atomic.LoadInt32(&sm.shutdown) != 0 {
  		return
  	}
  
  	log.Infof("New valid peer %s (%s)", peer, peer.UserAgent())
  
  	// Initialize the peer state
  	isSyncCandidate := sm.isSyncCandidate(peer)
  	sm.peerStates[peer] = &peerSyncState{
  		syncCandidate:   isSyncCandidate,
  		requestedTxns:   make(map[chainhash.Hash]struct{}),
  		requestedBlocks: make(map[chainhash.Hash]struct{}),
  	}
  
  	// Start syncing by choosing the best candidate if needed.
  	if isSyncCandidate && sm.syncPeer == nil {
  		sm.startSync()
  	}
  }
docs: // handleNewPeerMsg deals with new peers that have signalled they may
  // be considered as a sync peer (they have already successfully negotiated).  It
  // also starts syncing if needed.  It is invoked from the syncHandler goroutine.