-
Notifications
You must be signed in to change notification settings - Fork 790
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
Max election age precision #4549
Conversation
The unit test is a little messy and more complicated than it needs to be. |
There is no need to disable_request_loop because there are no voters on the network and the election will not be voted on and it will sit and wait. |
d5809d0
to
36c9460
Compare
36c9460
to
37484b6
Compare
Wouldn't it be simpler to return integer milliseconds instead of floating point seconds? |
Good point @simpago |
In general, I always favour integers and fixed point to floating point. Floating point comes with too many traps. I agree that returning milliseconds is preferable. |
I have updated it to use milliseconds |
But now the other floating point sticks out like a sore thumb... |
I don't see anything wrong with having the percentage value as a floating point value. Without any decimals it lacks the required precision. |
Floats are inaccurate and cause problems and it is good to avoid them. But in RPC code, I don't mind having floats, I would be worried if the floats were in the protocol code. |
max_election_age
is currently being casted asstd::chrono::seconds
which causes the value to be rounded to nearest second. This pr changes it to usedouble
and returns the value with 2 decimals.It's unfortunate that I did not notice this issue in the original PR.
The unit test is also updated to test that both election age values are greater than zero. On my machine they are 0.09 seconds during unit test.
I also implemented the syntax Colin suggested for
oldest_election_start
to avoid the if statement