Skip to content

Commit

Permalink
create local ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Feb 1, 2024
1 parent 939a4f0 commit 9e9b6ae
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions p2p/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,13 @@ func (ex *Exchange[H]) Head(ctx context.Context, opts ...header.HeadOption[H]) (
headerRespCh = make(chan H, len(peers))
)
for _, from := range peers {
ctx := ctx
go func(from peer.ID) {
// can skip error handling here as it returns an error if sanity check fails.
// we can be sure that our strings are ok.
peerIDBaggage, _ := baggage.NewMember("peerID", from.String())
b, _ := baggage.New(peerIDBaggage)
ctx = baggage.ContextWithBaggage(ctx, b)
_, newSpan := span.TracerProvider().Tracer("requesting peer").Start(ctx, "")
baggageCtx := baggage.ContextWithBaggage(ctx, b)
_, newSpan := span.TracerProvider().Tracer("requesting peer").Start(baggageCtx, "")
defer newSpan.End()

headers, err := ex.request(reqCtx, from, headerReq)
Expand Down

0 comments on commit 9e9b6ae

Please sign in to comment.