From 76857dbcdc76f9c95d89bdb85623508564b9d3b3 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Sun, 16 Sep 2018 10:40:10 +0200 Subject: [PATCH] fundingmanager: move handleFundingConfirmation out of waitForFundingWithTimeout Similarly to what we did in the previous commit, we move the responsibility of marking the channel open by calling handleFundingConfirmation out from waitForFundingWithTimeout to the caller. --- fundingmanager.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/fundingmanager.go b/fundingmanager.go index 6d46db4c..36450f3e 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -571,6 +571,14 @@ func (f *fundingManager) start() error { fndgLog.Debugf("ChannelID(%v) is now fully confirmed! "+ "(shortChanID=%v)", chanID, shortChanID) + err = f.handleFundingConfirmation(ch, *shortChanID) + if err != nil { + fndgLog.Errorf("unable to handle funding "+ + "confirmation for ChannelPoint(%v): %v", + ch.FundingOutpoint, err) + return + } + f.wg.Add(1) go f.advanceFundingState(ch, nil) }(channel) @@ -1635,6 +1643,14 @@ func (f *fundingManager) handleFundingCreated(fmsg *fundingCreatedMsg) { fndgLog.Debugf("ChannelID(%v) is now fully confirmed! "+ "(shortChanID=%v)", channelID, shortChanID) + err = f.handleFundingConfirmation(completeChan, *shortChanID) + if err != nil { + fndgLog.Errorf("unable to handle funding "+ + "confirmation for ChannelPoint(%v): %v", + completeChan.FundingOutpoint, err) + return + } + f.wg.Add(1) go f.advanceFundingState(completeChan, nil) @@ -1881,16 +1897,6 @@ func (f *fundingManager) waitForFundingWithTimeout(completeChan *channeldb.OpenC return } - err = f.handleFundingConfirmation( - completeChan, *shortChanID, - ) - if err != nil { - fndgLog.Errorf("unable to handle funding "+ - "confirmation for ChannelPoint(%v): %v", - completeChan.FundingOutpoint, err) - return - } - select { case confChan <- shortChanID: case <-f.quit: