breacharbiter: rename UnilateralClose -> RemoteUnilateralClose

Also ensure we exit on LocalUnilateralClose.
This commit is contained in:
Johan T. Halseth 2018-03-16 15:18:50 +01:00
parent 49f4a70e5a
commit 2fdc5992a4
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -696,6 +696,22 @@ func (b *breachArbiter) breachObserver(
brarLog.Debugf("Breach observer for ChannelPoint(%v) started ", brarLog.Debugf("Breach observer for ChannelPoint(%v) started ",
chanPoint) chanPoint)
gracefullyExit := func() {
// Launch a goroutine to cancel out this contract within the
// breachArbiter's main goroutine.
b.wg.Add(1)
go func() {
defer b.wg.Done()
select {
case b.settledContracts <- chanPoint:
case <-b.quit:
}
}()
b.cfg.CloseLink(&chanPoint, htlcswitch.CloseBreach)
}
select { select {
// 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.
@ -704,36 +720,14 @@ func (b *breachArbiter) breachObserver(
// The channel has been closed cooperatively, so we're done here. // The channel has been closed cooperatively, so we're done here.
case <-chainEvents.CooperativeClosure: case <-chainEvents.CooperativeClosure:
// Launch a goroutine to cancel out this contract within the gracefullyExit()
// breachArbiter's main goroutine.
b.wg.Add(1)
go func() {
defer b.wg.Done()
select {
case b.settledContracts <- chanPoint:
case <-b.quit:
}
}()
b.cfg.CloseLink(&chanPoint, htlcswitch.CloseBreach)
// The channel has been closed by a normal means: force closing with // The channel has been closed by a normal means: force closing with
// the latest commitment transaction. // the latest commitment transaction.
case <-chainEvents.UnilateralClosure: case <-chainEvents.LocalUnilateralClosure:
// Launch a goroutine to cancel out this contract within the gracefullyExit()
// breachArbiter's main goroutine. case <-chainEvents.RemoteUnilateralClosure:
b.wg.Add(1) gracefullyExit()
go func() {
defer b.wg.Done()
select {
case b.settledContracts <- chanPoint:
case <-b.quit:
}
}()
b.cfg.CloseLink(&chanPoint, htlcswitch.CloseBreach)
// A read from this channel indicates that a channel breach has been // A read from this channel indicates that a channel breach has been
// detected! So we notify the main coordination goroutine with the // detected! So we notify the main coordination goroutine with the