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.
This commit is contained in:
Johan T. Halseth 2018-08-09 10:03:14 +02:00
parent e9cc7492a9
commit 5deffd228c
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
2 changed files with 22 additions and 0 deletions

19
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
}

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