diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index 5fdb72c0..9fc3023a 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -301,6 +301,7 @@ func (c *ChainArbitrator) resolveContract(chanPoint wire.OutPoint, if ok { chainWatcher.Stop() } + delete(c.activeWatchers, chanPoint) c.Unlock() return nil diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index 0ee68313..44e40ce3 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -231,6 +231,7 @@ func (c *ChannelArbitrator) Start() error { // machine can act accordingly. c.state, err = c.log.CurrentState() if err != nil { + c.cfg.BlockEpochs.Cancel() return err } @@ -239,6 +240,7 @@ func (c *ChannelArbitrator) Start() error { _, bestHeight, err := c.cfg.ChainIO.GetBestBlock() if err != nil { + c.cfg.BlockEpochs.Cancel() return err } @@ -249,6 +251,7 @@ func (c *ChannelArbitrator) Start() error { uint32(bestHeight), chainTrigger, nil, ) if err != nil { + c.cfg.BlockEpochs.Cancel() return err } @@ -262,6 +265,7 @@ func (c *ChannelArbitrator) Start() error { // relaunch all contract resolvers. unresolvedContracts, err = c.log.FetchUnresolvedContracts() if err != nil { + c.cfg.BlockEpochs.Cancel() return err } @@ -301,8 +305,6 @@ func (c *ChannelArbitrator) Stop() error { close(c.quit) c.wg.Wait() - c.cfg.BlockEpochs.Cancel() - return nil } @@ -1289,7 +1291,10 @@ func (c *ChannelArbitrator) UpdateContractSignals(newSignals *ContractSignals) { func (c *ChannelArbitrator) channelAttendant(bestHeight int32) { // TODO(roasbeef): tell top chain arb we're done - defer c.wg.Done() + defer func() { + c.cfg.BlockEpochs.Cancel() + c.wg.Done() + }() for { select {