From 6fca22be2b19f216e830f084ee1b4a65527072b5 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 14 Apr 2020 10:50:45 -0700 Subject: [PATCH] htlcswitch/link: use return instead of break out There is no clean up logic after the loop, done purely to improve clarity. --- htlcswitch/link.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 27102d55..f474303e 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -1010,13 +1010,12 @@ func (l *channelLink) htlcManager() { go l.fwdPkgGarbager() } -out: for { // We must always check if we failed at some point processing // the last update before processing the next. if l.failed { l.log.Errorf("link failed, exiting htlcManager") - break out + return } // If the previous event resulted in a non-empty batch, resume @@ -1086,7 +1085,7 @@ out: l.cfg.Peer.WipeChannel(chanPoint) }() - break out + return case <-l.cfg.BatchTicker.Ticks(): // Attempt to extend the remote commitment chain @@ -1096,7 +1095,7 @@ out: if err := l.updateCommitTx(); err != nil { l.fail(LinkFailureError{code: ErrInternalError}, "unable to update commitment: %v", err) - break out + return } // A message from the switch was just received. This indicates @@ -1121,11 +1120,11 @@ out: fmt.Sprintf("process hodl queue: %v", err.Error()), ) - break out + return } case <-l.quit: - break out + return } } }