From 276c3844555a57486499cf38724945de01e0aee7 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 30 Dec 2016 16:28:20 -0800 Subject: [PATCH] breacharbiter: fix double channel close panic bug This commit fixes s bug in the breachArbiter which was introduced during the change that added the live channel hand off from an active peer. Rather than closing the settle channel of the _older_ breachObserver, the settle channel of the newer beachObserver was being closed. This would result in a panic once the channel itself was actually settled as the channel would be closed again. To fix this bug, we now properly close the channel of the old settle signal instead of the new one. --- breacharbiter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/breacharbiter.go b/breacharbiter.go index 0ea690e4..3d4d7c21 100644 --- a/breacharbiter.go +++ b/breacharbiter.go @@ -191,11 +191,11 @@ out: // the contract. So we'll cancel active watcher // goroutine to create a new instance with the latest // contract reference. - if _, ok := b.breachObservers[*chanPoint]; ok { + if oldSignal, ok := b.breachObservers[*chanPoint]; ok { brarLog.Infof("ChannelPoint(%v) is now live, "+ "abandoning state contract for live "+ "version", chanPoint) - close(settleSignal) + close(oldSignal) } b.breachObservers[*chanPoint] = settleSignal