diff --git a/voteslog/file.go b/voteslog/file.go index 898cab7..22a0140 100644 --- a/voteslog/file.go +++ b/voteslog/file.go @@ -20,6 +20,14 @@ var ErrExists = errors.New("msg with such index already exists") const maxSegments = 5 +// FileVotesLog is used to store votes and msgs on disk. +// +// Log is append-only, so we can't delete records from it, but log is divided into segments, which are rotated (oldest deleted) when +// segments number threshold is reached. +// Log is divided into two parts: msgs log and votes log. Each part has its own index, which is used to find record by its height. +// Index is stored in memory and loaded from disk on startup. +// +// This code is intentionally monomorphized for msgs and votes, generics can slow the app and make code more complicated. type FileVotesLog struct { // append-only log with proposed messages that node consumed msgs *os.File