-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: use go ticker instead of timer #14134
refactor: use go ticker instead of timer #14134
Conversation
hi @james-prysm wondering if you can take a look at this one |
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to use a ticker here , instead using the New Timer because we only have a 1 time action. Wait for Activation only triggers if there are 0 active keys while accounts are updated. the action no longer needs to run afterwards
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop finishes when activeValidatorExists is true, and using NewTicker will remove the need for the manual timer.Reset(waitTime) call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok that's fair, I think you're right on this and I was mistaken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this I'll go ahead and approve
What type of PR is this?
What does this PR do? Why is it needed?
Which issues(s) does this PR fix?
Fixes #
Other notes for review