From 7960b5240f797f2c1d0b2addd3031b412ab4b2bd Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 6 Dec 2017 16:30:50 -0800 Subject: [PATCH] peer: when processing a msg, skip he funding barrier if it's a ChanSync message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit is a follow up to the prior commit: as it’s possible for the channel_reestablish message to be sent *before* the channel has been fully confirmed, we’ll now ensure that we process it to the link even if the channel isn’t yet open. --- peer.go | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/peer.go b/peer.go index 5e86945e..9a17497b 100644 --- a/peer.go +++ b/peer.go @@ -583,13 +583,25 @@ func newChanMsgStream(p *peer, cid lnwire.ChannelID) *msgStream { fmt.Sprintf("Update stream for ChannelID(%x) created", cid), fmt.Sprintf("Update stream for ChannelID(%x) exiting", cid), func(msg lnwire.Message) { - // We'll send a message to the funding manager and wait iff an - // active funding process for this channel hasn't yet completed. - // We do this in order to account for the following scenario: we - // send the funding locked message to the other side, they - // immediately send a channel update message, but we haven't yet - // sent the channel to the channelManager. - p.server.fundingMgr.waitUntilChannelOpen(cid) + _, isChanSycMsg := msg.(*lnwire.ChannelReestablish) + + // If this is the chanSync message, then we'll develri + // it imemdately to the active link. + if !isChanSycMsg { + // We'll send a message to the funding manager + // and wait iff an active funding process for + // this channel hasn't yet completed. We do + // this in order to account for the following + // scenario: we send the funding locked message + // to the other side, they immediately send a + // channel update message, but we haven't yet + // sent the channel to the channelManager. + peerLog.Infof("waiting on chan open to deliver: %v", + spew.Sdump(msg)) + p.server.fundingMgr.waitUntilChannelOpen(cid) + } + + // TODO(roasbeef): only wait if not chan sync // Dispatch the commitment update message to the proper active // goroutine dedicated to this channel.