I am doing MIT 6.824, but meet some problems:
I pass args : &{1 2 0 -1} ,reply := AppendEntriesReply{} to example RequestVote RPC handler.
func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {
fmt.Println(args) // it is nil!
if args.term > rf.currentTerm {
rf.currentTerm = args.term
rf.state = Follower
}
if args.term <= rf.currentTerm {
reply.Granted = false
reply.Term = rf.currentTerm
}
if args.lastLogIndex >= len(rf.log) && (rf.votedFor == -1 || rf.votedFor == args.candidateId) {
reply.Granted = true
} else {
reply.Granted = false
}
reply.Term = rf.currentTerm
return
}
func (rf *Raft) sendRequestVote(server int, args *RequestVoteArgs, reply *RequestVoteReply) bool {
fmt.Println(args)
ok := rf.peers[server].Call("Raft.RequestVote", args, reply)
return ok
}
My RPC call do not pass the args. Why, but I am using the basic lib.