|
|
@@ -869,15 +869,15 @@ func (r *raft) loadState(state pb.HardState) {
|
|
|
r.Vote = state.Vote
|
|
|
}
|
|
|
|
|
|
-// pastElectionTimeout returns true if r.electionElapsed is greater than the
|
|
|
-// randomized election timeout in [electiontimeout, 2 * electiontimeout - 1].
|
|
|
-// Otherwise, it returns false.
|
|
|
+// pastElectionTimeout returns true iff r.electionElapsed is greater
|
|
|
+// than or equal to the randomized election timeout in
|
|
|
+// [electiontimeout, 2 * electiontimeout - 1].
|
|
|
func (r *raft) pastElectionTimeout() bool {
|
|
|
return r.electionElapsed >= r.randomizedElectionTimeout
|
|
|
}
|
|
|
|
|
|
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
|