Skip to content

Commit

Permalink
refactor: use go ticker instead of timer (#14134)
Browse files Browse the repository at this point in the history
Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 25, 2024
1 parent 4722446 commit aad29ff
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions beacon-chain/rpc/prysm/v1alpha1/validator/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@ func (vs *Server) WaitForActivation(req *ethpb.ValidatorActivationRequest, strea
}

waitTime := time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second
timer := time.NewTimer(waitTime)
defer timer.Stop()
ticker := time.NewTicker(waitTime)
defer ticker.Stop()

for {
timer.Reset(waitTime)
select {
// Pinging every slot for activation.
case <-timer.C:
case <-ticker.C:
activeValidatorExists, validatorStatuses, err := vs.activationStatus(stream.Context(), req.PublicKeys)
if err != nil {
return status.Errorf(codes.Internal, "Could not fetch validator status: %v", err)
Expand Down

0 comments on commit aad29ff

Please sign in to comment.