From bdbb33344ad8fe838d0592404c54041f67b8dbfd Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 19 Jan 2018 17:13:41 -0800 Subject: [PATCH] contractcourt: extend resolveContract to also stop any active chainWatcher --- contractcourt/chain_arbitrator.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index dd827622..df3a7cc0 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -273,17 +273,24 @@ func (c *ChainArbitrator) resolveContract(chanPoint wire.OutPoint, return err } - // Once this has been marked as resolved, we'll wipe the log that the - // channel arbitrator was using to store its persistent state. We do - // this after marking the channel resolved, as otherwise, the - // arbitrator would be re-created, and think it was starting from the - // default state. - if err := arbLog.WipeHistory(); err != nil { - return err + if arbLog != nil { + // Once this has been marked as resolved, we'll wipe the log + // that the channel arbitrator was using to store its + // persistent state. We do this after marking the channel + // resolved, as otherwise, the arbitrator would be re-created, + // and think it was starting from the default state. + if err := arbLog.WipeHistory(); err != nil { + return err + } } c.Lock() delete(c.activeChannels, chanPoint) + + chainWatcher, ok := c.activeWatchers[chanPoint] + if ok { + chainWatcher.Stop() + } c.Unlock() return nil