Skip to content

Commit

Permalink
add a new interface allEntries to RaftLog (talent-plan#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
niebayes authored Aug 29, 2022
1 parent 6df022c commit cfbc05d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions raft/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ func (l *RaftLog) maybeCompact() {
// Your Code Here (2C).
}

// allEntries return all the entries not compacted.
// note, exclude any dummy entries from the return value.
// note, this is one of the test stub functions you need to implement.
func (l *RaftLog) allEntries() []pb.Entry {
// Your Code Here (2A).
return nil
}

// unstableEntries return all the unstable entries
func (l *RaftLog) unstableEntries() []pb.Entry {
// Your Code Here (2A).
Expand Down
2 changes: 1 addition & 1 deletion raft/raft_paper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ func TestFollowerAppendEntries2AB(t *testing.T) {
for _, ent := range tt.wents {
wents = append(wents, *ent)
}
if g := r.RaftLog.entries; !reflect.DeepEqual(g, wents) {
if g := r.RaftLog.allEntries(); !reflect.DeepEqual(g, wents) {
t.Errorf("#%d: ents = %+v, want %+v", i, g, wents)
}
var wunstable []pb.Entry
Expand Down

0 comments on commit cfbc05d

Please sign in to comment.