From 33dda07b6246f2bceb866a024c25f8d6709336b7 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Tue, 28 Aug 2018 20:10:02 -0700 Subject: [PATCH 1/2] htlcswitch: return concrete error from GetLinksByInterface --- htlcswitch/switch.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index 2e5248a4..66283d8b 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -55,6 +55,10 @@ var ( // request. ErrSwitchExiting = errors.New("htlcswitch shutting down") + // ErrNoLinksFound is an error returned when we attempt to retrieve the + // active links in the switch for a specific destination. + ErrNoLinksFound = errors.New("no channel links found") + // zeroPreimage is the empty preimage which is returned when we have // some errors. zeroPreimage [sha256.Size]byte @@ -2105,8 +2109,7 @@ func (s *Switch) GetLinksByInterface(hop [33]byte) ([]ChannelLink, error) { func (s *Switch) getLinks(destination [33]byte) ([]ChannelLink, error) { links, ok := s.interfaceIndex[destination] if !ok { - return nil, fmt.Errorf("unable to locate channel link by "+ - "destination hop id %x", destination) + return nil, ErrNoLinksFound } channelLinks := make([]ChannelLink, 0, len(links)) From 16b412fb515db733e34f41129a74dcbc193466b6 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Tue, 28 Aug 2018 20:10:35 -0700 Subject: [PATCH 2/2] server: avoid logging error if no links are found In this commit, we avoid logging an error when the links associated with a peer are not found within its termination watcher. We do this to prevent a benign log message as the links have already been removed from the switch. --- server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index 9bd996f5..3ed06838 100644 --- a/server.go +++ b/server.go @@ -2449,8 +2449,9 @@ func (s *server) peerTerminationWatcher(p *peer, ready chan struct{}) { // // TODO(roasbeef): instead add a PurgeInterfaceLinks function? links, err := p.server.htlcSwitch.GetLinksByInterface(p.pubKeyBytes) - if err != nil { - srvrLog.Errorf("unable to get channel links: %v", err) + if err != nil && err != htlcswitch.ErrNoLinksFound { + srvrLog.Errorf("Unable to get channel links for %x: %v", + p.pubKeyBytes, err) } for _, link := range links {