breacharbiter: also cancel the channel's observer in case of close, or hand-off

This commit is contained in:
Olaoluwa Osuntokun committed 2017-11-23 23:10:16 -06:00
1 parent 1d65839bca
commit 923cbe62a0
1 file changed
+9 -4
+9 -4
View File
@@ -228,10 +228,10 @@ func (b *breachArbiter) Start() error {
// to be managed by the contractObserver. // to be managed by the contractObserver.
chanPoint := chanState.FundingOutpoint chanPoint := chanState.FundingOutpoint
if closeSummary, ok := closeSummaries[chanPoint]; ok { if closeSummary, ok := closeSummaries[chanPoint]; ok {
// Since this channel should not be open, we immediately // Since this channel should not be open, we
// notify the HTLC switch that this link should be // immediately notify the HTLC switch that this link
// closed, and that all activity on the link should // should be closed, and that all activity on the link
// cease. // should cease.
b.cfg.CloseLink(&chanState.FundingOutpoint, b.cfg.CloseLink(&chanState.FundingOutpoint,
htlcswitch.CloseBreach) htlcswitch.CloseBreach)
@@ -649,6 +649,7 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel,
// A read from this channel indicates that the contract has been // A read from this channel indicates that the contract has been
// settled cooperatively so we exit as our duties are no longer needed. // settled cooperatively so we exit as our duties are no longer needed.
case <-settleSignal: case <-settleSignal:
contract.CancelObserver()
contract.Stop() contract.Stop()
return return
@@ -667,6 +668,10 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel,
} }
}() }()
b.cfg.CloseLink(chanPoint, htlcswitch.CloseBreach)
contract.CancelObserver()
contract.Stop()
// Next, we'll launch a goroutine to wait until the closing // Next, we'll launch a goroutine to wait until the closing
// transaction has been confirmed so we can mark the contract // transaction has been confirmed so we can mark the contract
// as resolved in the database. This go routine is _not_ tracked // as resolved in the database. This go routine is _not_ tracked