don't try to get the last log entry if there aren't any

pull/463/head
John Shahid 2014-04-21 13:16:45 -04:00
parent a7b0475b7d
commit 462d6e9bc7
1 changed files with 3 additions and 0 deletions

View File

@ -322,6 +322,9 @@ func (s *RaftServer) CompactLog() {
func (s *RaftServer) CommittedAllChanges() bool {
entries := s.raftServer.LogEntries()
if len(entries) == 0 {
return false
}
lastIndex := entries[len(entries)-1].Index()
return s.raftServer.CommitIndex() == lastIndex
}