From 6e185c4bbdfed4f3dd40d43a252025fbe8ab7274 Mon Sep 17 00:00:00 2001 From: Viacheslav Gonkivskyi Date: Thu, 1 Feb 2024 16:28:53 +0200 Subject: [PATCH] fix race --- p2p/exchange.go | 1 + 1 file changed, 1 insertion(+) diff --git a/p2p/exchange.go b/p2p/exchange.go index 20b4cf74..1e8b5712 100644 --- a/p2p/exchange.go +++ b/p2p/exchange.go @@ -167,6 +167,7 @@ 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.