From 2c0d5e0f0d253073016a1693c7a06d21e6e0f06f Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 2 Feb 2017 17:28:05 -0800 Subject: [PATCH] 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. --- breacharbiter.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/breacharbiter.go b/breacharbiter.go index dd818a44..35c0029b 100644 --- a/breacharbiter.go +++ b/breacharbiter.go @@ -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