From 60b907a34f79ec00b6ce5b70460a4c4508cc62d6 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 25 Jun 2020 12:11:17 +0200 Subject: [PATCH] loopin: refactor htlc conf event loop --- loopin.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/loopin.go b/loopin.go index ab82c47..24a5337 100644 --- a/loopin.go +++ b/loopin.go @@ -406,20 +406,19 @@ func (s *loopInSwap) waitForHtlcConf(globalCtx context.Context) ( return nil, err } - for { + var conf *chainntnfs.TxConfirmation + for conf == nil { select { // P2WSH htlc confirmed. - case conf := <-confChanP2WSH: + case conf = <-confChanP2WSH: s.htlc = s.htlcP2WSH s.log.Infof("P2WSH htlc confirmed") - return conf, nil // NP2WSH htlc confirmed. - case conf := <-confChanNP2WSH: + case conf = <-confChanNP2WSH: s.htlc = s.htlcNP2WSH s.log.Infof("NP2WSH htlc confirmed") - return conf, nil // Conf ntfn error. case err := <-confErrP2WSH: @@ -438,6 +437,8 @@ func (s *loopInSwap) waitForHtlcConf(globalCtx context.Context) ( return nil, globalCtx.Err() } } + + return conf, nil } // publishOnChainHtlc checks whether there are still enough blocks left and if