From 71e080a2fb5c6d6b5fb0ed11e9f9bc0d0fdd1750 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 9 Apr 2019 19:47:00 -0700 Subject: [PATCH] chanrestore: don't exit with an error if we're already connected to the peer In this commit, we fix a bug in the existing logic for ConnectPeer that would cause an SCB restore to fail if we were already connected to the peer. To fix this, we now instead will just return with a success if we're already connected to the peer. --- chanrestore.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chanrestore.go b/chanrestore.go index 7aaada2f..c1611395 100644 --- a/chanrestore.go +++ b/chanrestore.go @@ -171,7 +171,16 @@ func (s *server) ConnectPeer(nodePub *btcec.PublicKey, addrs []net.Addr) error { // Attempt to connect to the peer using this full address. If // we're unable to connect to them, then we'll try the next // address in place of it. - if err := s.ConnectToPeer(netAddr, true); err != nil { + err := s.ConnectToPeer(netAddr, true) + + // If we're already connected to this peer, then we don't + // consider this an erorr, so we'll exit here. + if _, ok := err.(*errPeerAlreadyConnected); ok { + return nil + + } else if err != nil { + // Otherwise, something else happened, so we'll try the + // next address. ltndLog.Errorf("unable to connect to %v to "+ "complete SCB restore: %v", netAddr, err) continue