Fix comments of lab 3

This commit is contained in:
Yun-Sheng Chang
2024-02-18 20:39:24 -05:00
parent 5b5ae16e92
commit d6f2a7fb5c
2 changed files with 15 additions and 15 deletions

View File

@@ -551,7 +551,7 @@ func (cfg *config) wait(index int, n int, startTerm int) interface{} {
// if retry==true, may submit the command multiple
// times, in case a leader fails just after Start().
// if retry==false, calls Start() only once, in order
// to simplify the early Lab 2B tests.
// to simplify the early Lab 3B tests.
func (cfg *config) one(cmd interface{}, expectedServers int, retry bool) int {
t0 := time.Now()
starts := 0
@@ -605,7 +605,7 @@ func (cfg *config) one(cmd interface{}, expectedServers int, retry bool) int {
// start a Test.
// print the Test message.
// e.g. cfg.begin("Test (2B): RPC counts aren't too high")
// e.g. cfg.begin("Test (3B): RPC counts aren't too high")
func (cfg *config) begin(description string) {
fmt.Printf("%s ...\n", description)
cfg.t0 = time.Now()

View File

@@ -35,7 +35,7 @@ import (
// CommandValid to true to indicate that the ApplyMsg contains a newly
// committed log entry.
//
// in part 2D you'll want to send other kinds of messages (e.g.,
// in part 3D you'll want to send other kinds of messages (e.g.,
// snapshots) on the applyCh, but set CommandValid to false for these
// other uses.
type ApplyMsg struct {
@@ -43,7 +43,7 @@ type ApplyMsg struct {
Command interface{}
CommandIndex int
// For 2D:
// For 3D:
SnapshotValid bool
Snapshot []byte
SnapshotTerm int
@@ -58,7 +58,7 @@ type Raft struct {
me int // this peer's index into peers[]
dead int32 // set by Kill()
// Your data here (2A, 2B, 2C).
// Your data here (3A, 3B, 3C).
// Look at the paper's Figure 2 for a description of what
// state a Raft server must maintain.
@@ -70,7 +70,7 @@ func (rf *Raft) GetState() (int, bool) {
var term int
var isleader bool
// Your code here (2A).
// Your code here (3A).
return term, isleader
}
@@ -82,7 +82,7 @@ func (rf *Raft) GetState() (int, bool) {
// after you've implemented snapshots, pass the current snapshot
// (or nil if there's not yet a snapshot).
func (rf *Raft) persist() {
// Your code here (2C).
// Your code here (3C).
// Example:
// w := new(bytes.Buffer)
// e := labgob.NewEncoder(w)
@@ -98,7 +98,7 @@ func (rf *Raft) readPersist(data []byte) {
if data == nil || len(data) < 1 { // bootstrap without any state?
return
}
// Your code here (2C).
// Your code here (3C).
// Example:
// r := bytes.NewBuffer(data)
// d := labgob.NewDecoder(r)
@@ -119,7 +119,7 @@ func (rf *Raft) readPersist(data []byte) {
// service no longer needs the log through (and including)
// that index. Raft should now trim its log as much as possible.
func (rf *Raft) Snapshot(index int, snapshot []byte) {
// Your code here (2D).
// Your code here (3D).
}
@@ -127,18 +127,18 @@ func (rf *Raft) Snapshot(index int, snapshot []byte) {
// example RequestVote RPC arguments structure.
// field names must start with capital letters!
type RequestVoteArgs struct {
// Your data here (2A, 2B).
// Your data here (3A, 3B).
}
// example RequestVote RPC reply structure.
// field names must start with capital letters!
type RequestVoteReply struct {
// Your data here (2A).
// Your data here (3A).
}
// example RequestVote RPC handler.
func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {
// Your code here (2A, 2B).
// Your code here (3A, 3B).
}
// example code to send a RequestVote RPC to a server.
@@ -191,7 +191,7 @@ func (rf *Raft) Start(command interface{}) (int, int, bool) {
term := -1
isLeader := true
// Your code here (2B).
// Your code here (3B).
return index, term, isLeader
@@ -219,7 +219,7 @@ func (rf *Raft) killed() bool {
func (rf *Raft) ticker() {
for rf.killed() == false {
// Your code here (2A)
// Your code here (3A)
// Check if a leader election should be started.
@@ -246,7 +246,7 @@ func Make(peers []*labrpc.ClientEnd, me int,
rf.persister = persister
rf.me = me
// Your initialization code here (2A, 2B, 2C).
// Your initialization code here (3A, 3B, 3C).
// initialize from state persisted before a crash
rf.readPersist(persister.ReadRaftState())