mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: use rand.Intn instead of rand.Int and mod
This provides a better random distribution and is easier to read.
This commit is contained in:
parent
34375ef851
commit
5250784b09
@ -877,7 +877,7 @@ func (r *raft) pastElectionTimeout() bool {
|
||||
}
|
||||
|
||||
func (r *raft) resetRandomizedElectionTimeout() {
|
||||
r.randomizedElectionTimeout = r.electionTimeout + r.rand.Int()%r.electionTimeout
|
||||
r.randomizedElectionTimeout = r.electionTimeout + r.rand.Intn(r.electionTimeout)
|
||||
}
|
||||
|
||||
// checkQuorumActive returns true if the quorum is active from
|
||||
|
Loading…
x
Reference in New Issue
Block a user