Merge pull request #1417 from halseth/chanarb-stop

Properly stop ChannelArbitrators/blockEpocs
This commit is contained in:
Olaoluwa Osuntokun 2018-06-21 13:42:20 +01:00 committed by GitHub
commit 70217422b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

@ -301,6 +301,7 @@ func (c *ChainArbitrator) resolveContract(chanPoint wire.OutPoint,
if ok {
chainWatcher.Stop()
}
delete(c.activeWatchers, chanPoint)
c.Unlock()
return nil

@ -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 {