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.
This commit is contained in:
Wilmer Paulino 2018-09-21 17:04:43 -07:00
parent f13c1d2787
commit 99a4952239
No known key found for this signature in database
GPG Key ID: 6DF57B9F9514972F
2 changed files with 12 additions and 10 deletions

@ -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)
}
}
}()

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