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 7cb95ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 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
4 changes: 3 additions & 1 deletion 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

0 comments on commit 7cb95ef

Please sign in to comment.