From 84f6b707731de58a580a99048028dce3115c160a Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Thu, 7 Oct 2021 13:32:02 +0200 Subject: [PATCH] server: use deduped addrMap for connReq creation Use the addrMap for connReq creation to prevent creating duplicate connection requests if persistentPeerAddrs contains duplicate addresses. --- docs/release-notes/release-notes-0.14.0.md | 3 +++ server.go | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/release-notes/release-notes-0.14.0.md b/docs/release-notes/release-notes-0.14.0.md index 9a5516c9a..06521d9b1 100644 --- a/docs/release-notes/release-notes-0.14.0.md +++ b/docs/release-notes/release-notes-0.14.0.md @@ -460,6 +460,9 @@ you. certain channels couldn't be passed to `lncli getchaninfo` due to their 8-byte compact ID being too large for an int64. +* [Dedup stored peer addresses before creating connection requests to prevent + redundant connection requests](https://github.com/lightningnetwork/lnd/pull/5839) + ## Documentation The [code contribution guidelines have been updated to mention the new diff --git a/server.go b/server.go index 868325726..eba67a20f 100644 --- a/server.go +++ b/server.go @@ -3772,11 +3772,7 @@ func (s *server) connectToPersistentPeer(pubKeyStr string) { // Any addresses left in addrMap are new ones that we have not made // connection requests for. So create new connection requests for those. - for _, addr := range s.persistentPeerAddrs[pubKeyStr] { - if _, ok := addrMap[addr.String()]; !ok { - continue - } - + for _, addr := range addrMap { connReq := &connmgr.ConnReq{ Addr: addr, Permanent: true,