peer+server: remove persistent connections for peers with no open channels remaining

This commit is contained in:
Wilmer Paulino committed 2018-07-17 17:35:30 -07:00
1 parent 0e4d350e56
commit 38b52df51f
2 files changed
+31 -3

No files matched your search

+16
View File
@@ -1476,6 +1476,22 @@ func (s *server) establishPersistentConnections() error {
return nil
}
// prunePersistentPeerConnection removes all internal state related to
// persistent connections to a peer within the server. This is used to avoid
// persistent connection retries to peers we do not have any open channels with.
func (s *server) prunePersistentPeerConnection(compressedPubKey [33]byte) {
srvrLog.Infof("Pruning peer %x from persistent connections, number of "+
"open channels is now zero", compressedPubKey)
pubKeyStr := string(compressedPubKey[:])
s.mu.Lock()
delete(s.persistentPeers, pubKeyStr)
delete(s.persistentPeersBackoff, pubKeyStr)
s.cancelConnReqs(pubKeyStr, nil)
s.mu.Unlock()
}
// BroadcastMessage sends a request to the server to broadcast a set of
// messages to all peers other than the one specified by the `skips` parameter.
//