From 5deffd228cb0e66ca88dc56b7dbd9f349344b45a Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 9 Aug 2018 10:03:14 +0200 Subject: [PATCH] peer: call disableChannel with disabled=false after loading channels This to ensure now active channel is available in the router, for path finding, as it might have been disabled if the peer has been offline a while. --- peer.go | 19 +++++++++++++++++++ server.go | 3 +++ 2 files changed, 22 insertions(+) diff --git a/peer.go b/peer.go index c1faf6dd..f6366c80 100644 --- a/peer.go +++ b/peer.go @@ -318,6 +318,7 @@ func (p *peer) Start() error { // loadActiveChannels creates indexes within the peer for tracking all active // channels returned by the database. func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error { + var activeChans []wire.OutPoint for _, dbChan := range chans { lnChan, err := lnwallet.NewLightningChannel( p.server.cc.signer, p.server.witnessBeacon, dbChan, @@ -425,8 +426,26 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error { p.activeChanMtx.Lock() p.activeChannels[chanID] = lnChan p.activeChanMtx.Unlock() + + activeChans = append(activeChans, *chanPoint) } + // As a final measure we launch a goroutine that will ensure the + // channels are not currently disabled, as that will make us skip it + // during path finding. + go func() { + for _, chanPoint := range activeChans { + // Set the channel disabled=false by sending out a new + // 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) + } + } + }() + return nil } diff --git a/server.go b/server.go index 125e0425..c3a4379a 100644 --- a/server.go +++ b/server.go @@ -3112,6 +3112,9 @@ func (s *server) watchChannelStatus() { // We'll send out an update for all channels that have // had their status unchanged for longer than the limit. + // NOTE: We also make sure to activate any channel when + // we connect to a peer, to make them available for + // path finding immediately. for op, st := range status { disable := !st.active