From 239c8dd479bfb0dc8d74052615ef8d745297f1f8 Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Mon, 24 Nov 2014 21:47:12 -0800 Subject: [PATCH] raft: add comment to newLog --- raft/log.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/raft/log.go b/raft/log.go index fd9ccdae1..2591bba77 100644 --- a/raft/log.go +++ b/raft/log.go @@ -44,6 +44,8 @@ type raftLog struct { applied uint64 } +// newLog returns log using the given storage. It recovers the log to the state +// that it just commits and applies the lastest snapshot. func newLog(storage Storage) *raftLog { if storage == nil { log.Panic("storage must not be nil") @@ -68,7 +70,7 @@ func newLog(storage Storage) *raftLog { } func (l *raftLog) String() string { - return fmt.Sprintf("unstable=%d committed=%d applied=%d", l.unstable, l.committed, l.applied) + return fmt.Sprintf("unstable=%d committed=%d applied=%d len(unstableEntries)=%d", l.unstable, l.committed, l.applied, len(l.unstableEnts)) } // maybeAppend returns (0, false) if the entries cannot be appended. Otherwise,