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.
This commit is contained in:
Olaoluwa Osuntokun 2019-04-09 19:47:00 -07:00
parent 4b57fb199f
commit 71e080a2fb
No known key found for this signature in database
GPG Key ID: CE58F7F8E20FD9A2

View File

@ -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