From 7cb95ef6fd5c1bdadfb80e428a8ca4481cbc1300 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Fri, 11 Oct 2024 11:04:35 -0300 Subject: [PATCH] htlcswitch: fix linter warnings --- htlcswitch/switch.go | 10 ++++++++-- htlcswitch/switch_test.go | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index ec8155b01f..bc0e8e7f7f 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -1767,6 +1767,7 @@ out: func (s *Switch) Start() error { if !atomic.CompareAndSwapInt32(&s.started, 0, 1) { log.Warn("Htlc Switch already started") + return errors.New("htlc switch already started") } @@ -1782,15 +1783,19 @@ func (s *Switch) Start() error { s.htlcForwarder() }) if err != nil { - s.Stop() + // We are already stopping so we can ignore the error. + _ = s.Stop() err = fmt.Errorf("unable to start htlc forwarder: %w", err) log.Errorf("%v", err) + return err } if err := s.reforwardResponses(); err != nil { - s.Stop() + // We are already stopping so we can ignore the error. + _ = s.Stop() log.Errorf("unable to reforward responses: %v", err) + return err } @@ -1798,6 +1803,7 @@ func (s *Switch) Start() error { // We are already stopping so we can ignore the error. _ = s.Stop() log.Errorf("unable to reforward resolutions: %v", err) + return err } diff --git a/htlcswitch/switch_test.go b/htlcswitch/switch_test.go index 30bb7ba877..4825571698 100644 --- a/htlcswitch/switch_test.go +++ b/htlcswitch/switch_test.go @@ -1780,7 +1780,9 @@ func TestSwitchForwardCircuitPersistence(t *testing.T) { cdb2, err := channeldb.Open(tempPath) require.NoError(t, err, "unable to reopen channeldb") - t.Cleanup(func() { cdb2.Close() }) + t.Cleanup(func() { + require.NoError(t, cdb2.Close()) + }) s2, err := initSwitchWithDB(testStartingHeight, cdb2) require.NoError(t, err, "unable reinit switch")