From fb9bf054ccdd74a42b70456a03f221efe68d8cd9 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 20 Feb 2017 16:36:50 -0800 Subject: [PATCH] lnwallet: cancel the spend notification when a channel's closeObserver exits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit ensures that when a channel’s closeObserver is signaled to exit before a channel closure has been detected, then the resources dedicated to the pending spend notification can be freed up. --- lnwallet/channel.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 0d13f6ba..206d52de 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -709,9 +709,13 @@ func (lc *LightningChannel) closeObserver(channelCloseNtfn *chainntnfs.SpendEven return } - // Otherwise, we've be signalled to bail out early by the + // Otherwise, we've beeen signalled to bail out early by the // caller/maintainer of this channel. case <-lc.quit: + // As we're exiting before the spend notification has been + // triggered, we'll cancel the notificaiton intent so the + // ChainNotiifer can free up the resources. + channelCloseNtfn.Cancel() return }