func (rf *Raft) sendRequestVote(server int, args RequestVoteArgs, reply *RequestVoteReply) bool {
	ok := rf.peers[server].Call("Raft.RequestVote", args, reply)
	return ok
}
example code to send a RequestVote RPC to a server.
server is the index of the target server in rf.peers[].
expects RPC arguments in args.
fills in *reply with RPC reply, so caller should
pass &reply.
the types of the args and reply passed to Call() must be
the same as the types of the arguments declared in the
handler function (including whether they are pointers).

returns true if labrpc says the RPC was delivered.

if you're having trouble getting RPC to work, check that you've
capitalized all field names in structs passed over RPC, and
that the caller passes the address of the reply struct with &, not
the struct itself.
package raft
import (
	"bytes"
	"encoding/gob"
	"logicKV/labrpc"
	"sync"
)
const (
	ElectionTimeoutMin = 150
	ElectionTimeoutMax = 300
	HeartbeatTimeout   = 50
)
type ApplyMsg struct {
	Index       int
	Command     interface{}
	UseSnapshot bool    
	Snapshot    []byte  
}
type Raft struct {
	mu sync.Mutex
	peers     []labrpc.Client
	persister *Persister
	me        int  
	currentTerm int
	votedFor    int
	log         *Log
	commitIndex int
	lastApplied int
	state State
	apply chan ApplyMsg
}
func (rf *Raft) GetState() (int, bool) {
	rf.mu.Lock()
	defer rf.mu.Unlock()
	_, isLeader := rf.state.(*Leader)
	return rf.currentTerm, isLeader
}
func (rf *Raft) SetState(state State) {
	rf.state.Kill(rf)
	rf.state = state
}
func (rf *Raft) persist() {
	w := new(bytes.Buffer)
	e := gob.NewEncoder(w)
	e.Encode(rf.currentTerm)
	e.Encode(rf.votedFor)
	e.Encode(rf.log)
	data := w.Bytes()
	rf.persister.SaveRaftState(data)
	DPrintf("%d (unknown)  (term %d): persist: %d, %d, %v", rf.me, rf.currentTerm, rf.currentTerm, rf.votedFor, rf.log)
}
func (rf *Raft) readPersist(data []byte) {
	r := bytes.NewBuffer(data)
	d := gob.NewDecoder(r)
	d.Decode(&rf.currentTerm)
	d.Decode(&rf.votedFor)
	d.Decode(&rf.log)
	DPrintf("%d (unknown)  (term %d): read persist: %d, %d, %v", rf.me, rf.currentTerm, rf.currentTerm, rf.votedFor, rf.log)
}
func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) error {
	rf.mu.Lock()
	defer rf.mu.Unlock()
	rf.state.RequestVote(rf, args, reply)
	rf.persist()
	return nil
}
func (rf *Raft) AppendEntries(args AppendEntriesArgs, reply *AppendEntriesReply) error {
	rf.mu.Lock()
	defer rf.mu.Unlock()
	rf.state.AppendEntries(rf, args, reply)
	rf.persist()
	return nil
}