htlcswitch/link: only update contract signals on start if live link

This commit is contained in:
Conner Fromknecht 2018-07-12 18:16:32 -07:00 committed by Conner Fromknecht
parent 5f90973f76
commit b507d265b4
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -359,21 +359,6 @@ func (l *channelLink) Start() error {
log.Infof("ChannelLink(%v) is starting", l)
// Before we start the link, we'll update the ChainArbitrator with the
// set of new channel signals for this channel.
//
// TODO(roasbeef): split goroutines within channel arb to avoid
go func() {
err := l.cfg.UpdateContractSignals(&contractcourt.ContractSignals{
HtlcUpdates: l.htlcUpdates,
ShortChanID: l.channel.ShortChanID(),
})
if err != nil {
log.Errorf("Unable to update signals for "+
"ChannelLink(%v)", l)
}
}()
l.mailBox.ResetMessages()
l.overflowQueue.Start()
@ -401,6 +386,24 @@ func (l *channelLink) Start() error {
return fmt.Errorf("unable to trim circuits above "+
"local htlc index %d: %v", localHtlcIndex, err)
}
// Since the link is live, before we start the link we'll update
// the ChainArbitrator with the set of new channel signals for
// this channel.
//
// TODO(roasbeef): split goroutines within channel arb to avoid
go func() {
signals := &contractcourt.ContractSignals{
HtlcUpdates: l.htlcUpdates,
ShortChanID: l.channel.ShortChanID(),
}
err := l.cfg.UpdateContractSignals(signals)
if err != nil {
log.Errorf("Unable to update signals for "+
"ChannelLink(%v)", l)
}
}()
}
l.updateFeeTimer = time.NewTimer(l.randomFeeUpdateTimeout())