breacharbiter: stop the stale contract when a live contract appears

This commit modifies the logic of the contract hand-off within the
breachArbiter to ensure that only a single internal closeObserver
goroutine is ever active for a given contract.

This modification cleans up the logs in the case of multiple
reconnections and may possible eliminate some non-deterministic bugs
related to channel force closures.
This commit is contained in:
Olaoluwa Osuntokun 2017-02-02 17:28:05 -08:00
parent 62bcd59db4
commit 2c0d5e0f0d
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
1 changed files with 3 additions and 2 deletions

View File

@ -106,8 +106,8 @@ func (b *breachArbiter) Start() error {
channelsToWatch := make([]*lnwallet.LightningChannel,
len(activeChannels))
for i, chanState := range activeChannels {
channel, err := lnwallet.NewLightningChannel(nil, nil,
b.notifier, chanState)
channel, err := lnwallet.NewLightningChannel(nil, b.notifier,
chanState)
if err != nil {
brarLog.Errorf("unable to load channel from disk")
return err
@ -357,6 +357,7 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel,
// A read from this channel indicates that the contract has been
// settled cooperatively so we exit as our duties are no longer needed.
case <-settleSignal:
contract.Stop()
return
// A read from this channel indicates that a channel breach has been