From 99a4952239d7def54b4e279a218b7c8be475a90d Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Fri, 21 Sep 2018 17:04:43 -0700 Subject: [PATCH] server+peer: check ErrEdgeNotFound when enabling/disabling a channel In this commit, we also check ErrEdgeNotFound when attempting to send an active/inactive channel update for a channel to the network. We do this as it's possible that a channel has confirmed, but it still does not meet the required number of confirmations to be publicly announced. --- peer.go | 6 +++--- server.go | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/peer.go b/peer.go index d438a4701..659ccd2ee 100644 --- a/peer.go +++ b/peer.go @@ -505,9 +505,9 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error { // ChannelUpdate. If this channel is already active, // the update won't be sent. err := p.server.announceChanStatus(chanPoint, false) - if err != nil { - peerLog.Errorf("unable to send out active "+ - "channel update: %v", err) + if err != nil && err != channeldb.ErrEdgeNotFound { + srvrLog.Errorf("Unable to enable channel %v: %v", + chanPoint, err) } } }() diff --git a/server.go b/server.go index 4c9ce4c0a..d87f6e92a 100644 --- a/server.go +++ b/server.go @@ -2847,8 +2847,6 @@ func (s *server) announceChanStatus(op wire.OutPoint, disabled bool) error { return nil } - srvrLog.Debugf("Announcing channel(%v) disabled=%v", op, disabled) - // Retrieve the latest update for this channel. We'll use this // as our starting point to send the new update. chanUpdate, err := s.fetchLastChanUpdateByOutPoint(op) @@ -2888,6 +2886,8 @@ func (s *server) announceChanStatus(op wire.OutPoint, disabled bool) error { return err } + srvrLog.Debugf("Announcing channel(%v) disabled=%v", op, disabled) + // Once signed, we'll send the new update to all of our peers. if err := s.applyChannelUpdate(chanUpdate); err != nil { return err @@ -3053,8 +3053,8 @@ func (s *server) watchChannelStatus() { newStatus := make(map[wire.OutPoint]activeStatus) for _, c := range channels { // We'll skip any private channels, as they - // aren't used for routing within the network - // by other nodes. + // aren't used for routing within the network by + // other nodes. if c.ChannelFlags&lnwire.FFAnnounceChannel == 0 { continue } @@ -3113,10 +3113,12 @@ func (s *server) watchChannelStatus() { delete(status, op) err = s.announceChanStatus(op, disable) - if err != nil { + if err != nil && + err != channeldb.ErrEdgeNotFound { + srvrLog.Errorf("Unable to "+ - "disable channel: %v", - err) + "disable channel %v: %v", + op, err) } } }