Skip to content

Commit

Permalink
avoid printing err if parent ctx is done
Browse files Browse the repository at this point in the history
  • Loading branch information
amirylm committed Oct 20, 2023
1 parent e999f5c commit 5e08b24
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/don/localdon.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (d *mockedDon) run(interval time.Duration, subscribedDONs ...string) {
case <-ctx.Done():
return
case <-ticker.C:
d.broadcast(d.nextReport())
d.broadcast(ctx, d.nextReport())
}
}
})
Expand Down Expand Up @@ -102,7 +102,7 @@ func (d *mockedDon) nextReport() *MockedSignedReport {
return r
}

func (d *mockedDon) broadcast(r *MockedSignedReport) {
func (d *mockedDon) broadcast(pctx context.Context, r *MockedSignedReport) {
for _, n := range d.nodes {
node := n
d.threadControl.Go(func(ctx context.Context) {
Expand All @@ -114,7 +114,7 @@ func (d *mockedDon) broadcast(r *MockedSignedReport) {
// return
// }
if err := node.Transmitter.Transmit(ctx, r, d.id); err != nil {
if strings.Contains(err.Error(), "validation ignored") || ctx.Err() != nil {
if strings.Contains(err.Error(), "validation ignored") || ctx.Err() != nil || pctx.Err() != nil {
return
}
fmt.Printf("failed to publish report on don %s: %s\n", d.id, err)
Expand Down

0 comments on commit 5e08b24

Please sign in to comment.