Skip to content

Commit

Permalink
htlcswitch: fix linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
starius committed Oct 24, 2024
1 parent 23ed7fa commit 662c47b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions htlcswitch/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand All @@ -1782,22 +1783,27 @@ 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
}

if err := s.reforwardResolutions(); err != nil {
// We are already stopping so we can ignore the error.
_ = s.Stop()
log.Errorf("unable to reforward resolutions: %v", err)

return err
}

Expand Down
6 changes: 4 additions & 2 deletions htlcswitch/switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -3226,7 +3228,7 @@ func TestSwitchGetAttemptResultStress(t *testing.T) {
// s.Stop() happens in the middle of GetAttemptResult series.
// The value 10ms was found empirically - this time is needed
// to expose the race condition (as a crash under -race) in the
// unfixed version of Switch, before GoroutineManager was added.
// version of Switch before GoroutineManager was added.
time.Sleep(10 * time.Millisecond)

require.NoError(t, s.Stop())
Expand Down

0 comments on commit 662c47b

Please sign in to comment.