code: func (sw *Switch) StopPeerForError(peer *Peer, reason interface{}) {
  	addr := NewNetAddress(peer.Addr())
  	log.Notice("Stopping peer for error", "peer", peer, "error", reason)
  	sw.stopAndRemovePeer(peer, reason)
  
  	if peer.IsPersistent() {
  		go func() {
  			log.Notice("Reconnecting to peer", "peer", peer)
  			for i := 1; i < reconnectAttempts; i++ {
  				if !sw.IsRunning() {
  					return
  				}
  
  				peer, err := sw.DialPeerWithAddress(addr, true)
  				if err != nil {
  					if i == reconnectAttempts {
  						log.Notice("Error reconnecting to peer. Giving up", "tries", i, "error", err)
  						return
  					}
  					log.Notice("Error reconnecting to peer. Trying again", "tries", i, "error", err)
  					time.Sleep(reconnectInterval)
  					continue
  				}
  
  				log.Notice("Reconnected to peer", "peer", peer)
  				return
  			}
  		}()
  	}
  }
docs: // Disconnect from a peer due to external error, retry if it is a persistent peer.
  // TODO: make record depending on reason.