From ee2eec61883415c7b1ff0fe8f96e4834235e9838 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 2 Oct 2017 13:11:26 +0200 Subject: [PATCH] peer: ignore new channel requests for already active channels. --- peer.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/peer.go b/peer.go index 73e62f55..c6dbc0c6 100644 --- a/peer.go +++ b/peer.go @@ -1003,10 +1003,19 @@ out: chanID := lnwire.NewChanIDFromOutPoint(chanPoint) newChan := newChanReq.channel - // First, we'll add this channel to the set of active + // Make sure this channel is not already active. + p.activeChanMtx.Lock() + if _, ok := p.activeChannels[chanID]; ok { + peerLog.Infof("Already have ChannelPoint(%v), ignoring.", chanPoint) + p.activeChanMtx.Unlock() + close(newChanReq.done) + newChanReq.channel.Stop() + continue + } + + // If not already active, we'll add this channel to the set of active // channels, so we can look it up later easily // according to its channel ID. - p.activeChanMtx.Lock() p.activeChannels[chanID] = newChan p.activeChanMtx.Unlock()