diff --git a/eth/backend.go b/eth/backend.go index 5bca53099..fcff82593 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -641,8 +641,12 @@ func (s *Ethereum) Protocols() []p2p.Protocol { // Ethereum protocol implementation. func (s *Ethereum) Start() error { for i := range s.sentries { - go download.RecvMessageLoop(s.downloadV2Ctx, s.sentries[i], s.downloadServer, nil) - go download.RecvUploadMessageLoop(s.downloadV2Ctx, s.sentries[i], s.downloadServer, nil) + go func(i int) { + download.RecvMessageLoop(s.downloadV2Ctx, s.sentries[i], s.downloadServer, nil) + }(i) + go func(i int) { + download.RecvUploadMessageLoop(s.downloadV2Ctx, s.sentries[i], s.downloadServer, nil) + }(i) } go Loop(s.downloadV2Ctx, s.chainKV, s.stagedSync2, s.downloadServer, s.events, s.config.StateStream, s.waitForStageLoopStop) diff --git a/turbo/stages/stageloop.go b/turbo/stages/stageloop.go index f0b32d32c..942201f48 100644 --- a/turbo/stages/stageloop.go +++ b/turbo/stages/stageloop.go @@ -311,8 +311,10 @@ func NewStagedSync2( stagedsync.StageCallTracesCfg(db, 0, batchSize, tmpdir, controlServer.ChainConfig, controlServer.Engine), stagedsync.StageTxLookupCfg(db, tmpdir), stagedsync.StageTxPoolCfg(db, txPool, func() { - for _, s := range txPoolServer.Sentries { - go txpool.RecvTxMessageLoop(ctx, s, controlServer, txPoolServer.HandleInboundMessage, nil) + for i := range txPoolServer.Sentries { + go func(i int) { + txpool.RecvTxMessageLoop(ctx, txPoolServer.Sentries[i], controlServer, txPoolServer.HandleInboundMessage, nil) + }(i) } txPoolServer.TxFetcher.Start() }),