server: prevent adding peers if already disconnected

This addresses an issue where the server ends up tracking a peer that
has been disconnected due to it processing a peer's `done` message
before its `add` message.
This commit is contained in:
Wilmer Paulino 2019-10-11 18:29:09 -04:00
parent 769c4e152f
commit baeb789a7d
No known key found for this signature in database
GPG key ID: 6DF57B9F9514972F

View file

@ -1563,7 +1563,7 @@ func (s *server) handleUpdatePeerHeights(state *peerState, umsg updatePeerHeight
// handleAddPeerMsg deals with adding new peers. It is invoked from the // handleAddPeerMsg deals with adding new peers. It is invoked from the
// peerHandler goroutine. // peerHandler goroutine.
func (s *server) handleAddPeerMsg(state *peerState, sp *serverPeer) bool { func (s *server) handleAddPeerMsg(state *peerState, sp *serverPeer) bool {
if sp == nil { if sp == nil || !sp.Connected() {
return false return false
} }