add a new interface allEntries to RaftLog (#418)

This commit is contained in:
niebayes 2022-08-29 11:31:40 +08:00 committed by GitHub
parent 6df022c85d
commit cfbc05df7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -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).

View File

@ -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