mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: rename log.isOk to log.matchTerm
This commit is contained in:
parent
4c609ec59c
commit
8f3d109c18
@ -20,7 +20,7 @@ func newLog() *log {
|
||||
}
|
||||
|
||||
func (l *log) maybeAppend(index, logTerm int, ents ...Entry) bool {
|
||||
if l.isOk(index, logTerm) {
|
||||
if l.matchTerm(index, logTerm) {
|
||||
l.append(index, ents...)
|
||||
return true
|
||||
}
|
||||
@ -58,7 +58,7 @@ func (l *log) isUpToDate(i, term int) bool {
|
||||
return term > e.Term || (term == e.Term && i >= l.len())
|
||||
}
|
||||
|
||||
func (l *log) isOk(i, term int) bool {
|
||||
func (l *log) matchTerm(i, term int) bool {
|
||||
if i > l.len() {
|
||||
return false
|
||||
}
|
||||
|
@ -132,10 +132,6 @@ func (sm *stateMachine) poll(addr int, v bool) (granted int) {
|
||||
return granted
|
||||
}
|
||||
|
||||
func (sm *stateMachine) isLogOk(i, term int) bool {
|
||||
return sm.log.isOk(i, term)
|
||||
}
|
||||
|
||||
// send persists state to stable storage and then sends to its mailbox
|
||||
func (sm *stateMachine) send(m Message) {
|
||||
m.From = sm.addr
|
||||
@ -276,7 +272,7 @@ func (sm *stateMachine) Step(m Message) {
|
||||
}
|
||||
|
||||
handleAppendEntries := func() {
|
||||
if sm.isLogOk(m.Index, m.LogTerm) {
|
||||
if sm.log.matchTerm(m.Index, m.LogTerm) {
|
||||
sm.log.commit = m.Commit
|
||||
sm.log.append(m.Index, m.Entries...)
|
||||
sm.send(Message{To: m.From, Type: msgAppResp, Index: sm.li()})
|
||||
|
Loading…
x
Reference in New Issue
Block a user