mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: remove sm.voteWorthy
This commit is contained in:
parent
bee9d8bea5
commit
1f0e13e956
@ -188,10 +188,6 @@ func (sm *stateMachine) q() int {
|
||||
return sm.k/2 + 1
|
||||
}
|
||||
|
||||
func (sm *stateMachine) voteWorthy(i, term int) bool {
|
||||
return sm.log.isUpToDate(i, term)
|
||||
}
|
||||
|
||||
func (sm *stateMachine) becomeFollower(term, lead int) {
|
||||
sm.reset()
|
||||
sm.term = term
|
||||
@ -305,7 +301,7 @@ func (sm *stateMachine) Step(m Message) {
|
||||
case msgApp:
|
||||
handleAppendEntries()
|
||||
case msgVote:
|
||||
if sm.voteWorthy(m.Index, m.LogTerm) {
|
||||
if sm.log.isUpToDate(m.Index, m.LogTerm) {
|
||||
sm.send(Message{To: m.From, Type: msgVoteResp, Index: sm.log.lastIndex()})
|
||||
} else {
|
||||
sm.send(Message{To: m.From, Type: msgVoteResp, Index: -1})
|
||||
|
Loading…
x
Reference in New Issue
Block a user