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:
Tamir Duberstein 2016-04-05 14:21:43 -04:00
parent 34375ef851
commit 5250784b09

View File

@ -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