Skip to content

Commit

Permalink
only append a single error for session cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Dec 31, 2024
1 parent 9371b17 commit 0b923ed
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions mixing/mixclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,24 @@ func (c *Client) sendLocalPeerMsgs(ctx context.Context, deadline time.Time, s *s
}

errs := make([]error, 0, len(msgs))
for i := range msgs {
m := msgs[i]

var sessionCancelledState bool
sessionCancelled := func() bool {
if sessionCancelledState {
return true
}
if err := ctx.Err(); err != nil {
err := fmt.Errorf("session cancelled: %w", err)
errs = append(errs, err)
sessionCancelledState = true
return true
}
return false
}

for i := range msgs {
m := msgs[i]
if sessionCancelled() {
continue
}
if err := m.p.ctx.Err(); err != nil {
Expand All @@ -562,8 +576,7 @@ func (c *Client) sendLocalPeerMsgs(ctx context.Context, deadline time.Time, s *s
continue
}
time.Sleep(time.Until(m.sendTime))
if err := ctx.Err(); err != nil {
errs = append(errs, err)
if sessionCancelled() {
continue
}
// TODO: handle send deadline in wallet.SubmitMixMessage.
Expand Down

0 comments on commit 0b923ed

Please sign in to comment.