typeRaftstruct{musync.Mutex// Lock to protect shared access to this peer's statepeers[]*labrpc.ClientEnd// RPC end points of all peerspersister*Persister// Object to hold this peer's persisted statemeint// this peer's index into peers[]deadint32// set by Kill()// 2A STARTcurrentTermint// 当前任期votedForint// 投票给谁peersVoteGranted[]bool// 已获得的选票roleint// 角色 follower, candidate, leaderheartBeatTimeOuttime.Time// 上一次收到心跳包的时间+随即选举超时时间(在收到心跳包后再随机一个)// 2A End}typeRequestVoteArgsstruct{// 2A StartCandidateTermint// 候选人TermCandidateIndexint// 候选人Index// 2A End}typeRequestVoteReplystruct{// 2A StartFollowerTermint// 当前任期号,以便候选人更新自己的任期号VotGrantedbool// 候选人是否被投票// 2A END}// AppendEntriesArgs 心跳/追加包typeAppendEntriesArgsstruct{LeaderTermint// leader's termLeaderIndexint// leader's index}typeAppendEntriesReplystruct{FollowerTermint// follower的term,用来更新leader自己的termSuccessbool// 是否成功}