Skip to content

Commit

Permalink
chanrestore: don't exit with an error if we're already connected to t…
Browse files Browse the repository at this point in the history
…he 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.
  • Loading branch information
Roasbeef committed Apr 11, 2019
1 parent 4b57fb1 commit 71e080a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion chanrestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 71e080a

Please sign in to comment.