contractcourt: channel arbitrators now exit on co-op close of the channel
This commit is contained in:
parent
62f951a969
commit
723bfb0eac
@ -215,7 +215,7 @@ func NewChannelArbitrator(cfg ChannelArbitratorConfig,
|
|||||||
// Start starts all the goroutines that the ChannelArbitrator needs to operate.
|
// Start starts all the goroutines that the ChannelArbitrator needs to operate.
|
||||||
func (c *ChannelArbitrator) Start() error {
|
func (c *ChannelArbitrator) Start() error {
|
||||||
if !atomic.CompareAndSwapInt32(&c.started, 0, 1) {
|
if !atomic.CompareAndSwapInt32(&c.started, 0, 1) {
|
||||||
return fmt.Errorf("already started")
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -287,12 +287,14 @@ func (c *ChannelArbitrator) Start() error {
|
|||||||
// Stop signals the ChannelArbitrator for a graceful shutdown.
|
// Stop signals the ChannelArbitrator for a graceful shutdown.
|
||||||
func (c *ChannelArbitrator) Stop() error {
|
func (c *ChannelArbitrator) Stop() error {
|
||||||
if !atomic.CompareAndSwapInt32(&c.stopped, 0, 1) {
|
if !atomic.CompareAndSwapInt32(&c.stopped, 0, 1) {
|
||||||
return fmt.Errorf("already shutting down")
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Stopping ChannelArbitrator(%v)", c.cfg.ChanPoint)
|
log.Debugf("Stopping ChannelArbitrator(%v)", c.cfg.ChanPoint)
|
||||||
|
|
||||||
|
if c.cfg.ChainEvents.Cancel != nil {
|
||||||
c.cfg.ChainEvents.Cancel()
|
c.cfg.ChainEvents.Cancel()
|
||||||
|
}
|
||||||
|
|
||||||
for _, activeResolver := range c.activeResolvers {
|
for _, activeResolver := range c.activeResolvers {
|
||||||
activeResolver.Stop()
|
activeResolver.Stop()
|
||||||
@ -1346,6 +1348,13 @@ func (c *ChannelArbitrator) channelAttendant(bestHeight int32,
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// We've cooperatively closed the channel, so we're no longer
|
||||||
|
// needed.
|
||||||
|
case <-c.cfg.ChainEvents.CooperativeClosure:
|
||||||
|
log.Infof("ChannelArbitrator(%v) closing due to co-op "+
|
||||||
|
"closure", c.cfg.ChanPoint)
|
||||||
|
return
|
||||||
|
|
||||||
// The remote party has broadcast the commitment on-chain.
|
// The remote party has broadcast the commitment on-chain.
|
||||||
// We'll examine our state to determine if we need to act at
|
// We'll examine our state to determine if we need to act at
|
||||||
// all.
|
// all.
|
||||||
|
Loading…
Reference in New Issue
Block a user