diff --git a/beacon-chain/sync/rpc_status.go b/beacon-chain/sync/rpc_status.go index 6dbbe52bc88..3370a2ff883 100644 --- a/beacon-chain/sync/rpc_status.go +++ b/beacon-chain/sync/rpc_status.go @@ -24,17 +24,19 @@ func (r *Service) maintainPeerStatuses() { interval := time.Duration(params.BeaconConfig().SecondsPerSlot*params.BeaconConfig().SlotsPerEpoch/2) * time.Second runutil.RunEvery(r.ctx, interval, func() { for _, pid := range r.p2p.Peers().Connected() { - // If the status hasn't been updated in the recent interval time. - lastUpdated, err := r.p2p.Peers().ChainStateLastUpdated(pid) - if err != nil { - // Peer has vanished; nothing to do - continue - } - if roughtime.Now().After(lastUpdated.Add(interval)) { - if err := r.sendRPCStatusRequest(r.ctx, pid); err != nil { - log.WithField("peer", pid).WithError(err).Error("Failed to request peer status") + go func(id peer.ID) { + // If the status hasn't been updated in the recent interval time. + lastUpdated, err := r.p2p.Peers().ChainStateLastUpdated(id) + if err != nil { + // Peer has vanished; nothing to do. + return } - } + if roughtime.Now().After(lastUpdated.Add(interval)) { + if err := r.sendRPCStatusRequest(r.ctx, id); err != nil { + log.WithField("peer", id).WithError(err).Error("Failed to request peer status") + } + } + }(pid) } }) }