Skip to content
Snippets Groups Projects
Commit f13a4fc1 authored by djq2's avatar djq2
Browse files

moving

parent 53f22ac7
No related branches found
No related tags found
No related merge requests found
...@@ -238,8 +238,20 @@ func (rf *Raft) AppendEntries(args *AppendEntriesArgs, reply *AppendEntriesReply ...@@ -238,8 +238,20 @@ func (rf *Raft) AppendEntries(args *AppendEntriesArgs, reply *AppendEntriesReply
} }
} else { } else {
//add else statment later to handle optimization
reply.Success = false reply.Success = false
if args.PrevLogIndex >= len(rf.log) {
reply.ConflictIdx = len(rf.log) - 1
reply.ConflictTerm = -1
} else {
wrongTerm := rf.log[args.PrevLogIndex].Term
reply.ConflictTerm = wrongTerm
for i := 0; i < len(rf.log); i++ {
if rf.log[i].Term == reply.ConflictTerm{
reply.ConflictIdx = i
break
}
}
}
} }
reply.Term = rf.currentTerm reply.Term = rf.currentTerm
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment