Documentation ¶
Index ¶
- Constants
- func CreateCheckpointWriter(dir string, fileNo int) (io.WriteCloser, error)
- func CreateCheckpointWriterForFile(filename string) (io.WriteCloser, error)
- func EncodeDelete(rootHash ledger.RootHash) []byte
- func EncodeUpdate(update *ledger.TrieUpdate) []byte
- func LoadCheckpoint(filepath string) (*flattener.FlattenedForest, error)
- func NumberToFilename(n int) string
- func NumberToFilenamePart(n int) string
- func StoreCheckpoint(forestSequencing *flattener.FlattenedForest, writer io.WriteCloser) error
- type Checkpointer
- func (c *Checkpointer) Checkpoint(to int, targetWriter func() (io.WriteCloser, error)) error
- func (c *Checkpointer) CheckpointWriter(to int) (io.WriteCloser, error)
- func (c *Checkpointer) HasRootCheckpoint() (bool, error)
- func (c *Checkpointer) LatestCheckpoint() (int, error)
- func (c *Checkpointer) LoadCheckpoint(checkpoint int) (*flattener.FlattenedForest, error)
- func (c *Checkpointer) LoadRootCheckpoint() (*flattener.FlattenedForest, error)
- func (c *Checkpointer) NotCheckpointedSegments() (from, to int, err error)
- type Compactor
- type LedgerWAL
- func (w *LedgerWAL) Close() error
- func (w *LedgerWAL) NewCheckpointer() (*Checkpointer, error)
- func (w *LedgerWAL) RecordDelete(rootHash ledger.RootHash) error
- func (w *LedgerWAL) RecordUpdate(update *ledger.TrieUpdate) error
- func (w *LedgerWAL) Replay(checkpointFn func(forestSequencing *flattener.FlattenedForest) error, ...) error
- func (w *LedgerWAL) ReplayLogsOnly(checkpointFn func(forestSequencing *flattener.FlattenedForest) error, ...) error
- func (w *LedgerWAL) ReplayOnForest(forest *mtrie.Forest) error
- type SyncOnCloseFile
- type WALOperation
Constants ¶
View Source
const MagicBytes uint16 = 0x2137
View Source
const RootCheckpointFilename = "root.checkpoint"
View Source
const SegmentSize = 32 * 1024 * 1024
View Source
const VersionV1 uint16 = 0x01
View Source
const VersionV2 uint16 = 0x02
Variables ¶
This section is empty.
Functions ¶
func CreateCheckpointWriter ¶
func CreateCheckpointWriter(dir string, fileNo int) (io.WriteCloser, error)
func CreateCheckpointWriterForFile ¶
func CreateCheckpointWriterForFile(filename string) (io.WriteCloser, error)
func EncodeDelete ¶
func EncodeUpdate ¶
func EncodeUpdate(update *ledger.TrieUpdate) []byte
func LoadCheckpoint ¶
func LoadCheckpoint(filepath string) (*flattener.FlattenedForest, error)
func NumberToFilename ¶
func NumberToFilenamePart ¶
func StoreCheckpoint ¶
func StoreCheckpoint(forestSequencing *flattener.FlattenedForest, writer io.WriteCloser) error
Types ¶
type Checkpointer ¶
type Checkpointer struct {
// contains filtered or unexported fields
}
func NewCheckpointer ¶
func NewCheckpointer(wal *LedgerWAL, keyByteSize int, forestCapacity int) *Checkpointer
func (*Checkpointer) Checkpoint ¶
func (c *Checkpointer) Checkpoint(to int, targetWriter func() (io.WriteCloser, error)) error
Checkpoint creates new checkpoint stopping at given segment
func (*Checkpointer) CheckpointWriter ¶
func (c *Checkpointer) CheckpointWriter(to int) (io.WriteCloser, error)
func (*Checkpointer) HasRootCheckpoint ¶
func (c *Checkpointer) HasRootCheckpoint() (bool, error)
func (*Checkpointer) LatestCheckpoint ¶
func (c *Checkpointer) LatestCheckpoint() (int, error)
LatestCheckpoint returns number of latest checkpoint or -1 if there are no checkpoints
func (*Checkpointer) LoadCheckpoint ¶
func (c *Checkpointer) LoadCheckpoint(checkpoint int) (*flattener.FlattenedForest, error)
func (*Checkpointer) LoadRootCheckpoint ¶
func (c *Checkpointer) LoadRootCheckpoint() (*flattener.FlattenedForest, error)
func (*Checkpointer) NotCheckpointedSegments ¶
func (c *Checkpointer) NotCheckpointedSegments() (from, to int, err error)
NotCheckpointedSegments - returns numbers of segments which are not checkpointed yet, or -1, -1 if there are no segments
type Compactor ¶
func NewCompactor ¶
func NewCompactor(checkpointer *Checkpointer, interval time.Duration, checkpointDistance uint) *Compactor
type LedgerWAL ¶
type LedgerWAL struct {
// contains filtered or unexported fields
}
func NewWAL ¶
func NewWAL(logger log.Logger, reg prometheus.Registerer, dir string, forestCapacity int, pathByteSize int, segmentSize int) (*LedgerWAL, error)
TODO use real logger and metrics, but that would require passing them to Trie storage
func (*LedgerWAL) NewCheckpointer ¶
func (w *LedgerWAL) NewCheckpointer() (*Checkpointer, error)
NewCheckpointer returns a Checkpointer for this WAL
func (*LedgerWAL) RecordUpdate ¶
func (w *LedgerWAL) RecordUpdate(update *ledger.TrieUpdate) error
func (*LedgerWAL) ReplayLogsOnly ¶
type SyncOnCloseFile ¶
func (*SyncOnCloseFile) Close ¶
func (s *SyncOnCloseFile) Close() error
func (*SyncOnCloseFile) Sync ¶ added in v0.12.0
func (s *SyncOnCloseFile) Sync() error
type WALOperation ¶
type WALOperation uint8
const WALDelete WALOperation = 2
const WALUpdate WALOperation = 1
func Decode ¶
func Decode(data []byte) (operation WALOperation, rootHash ledger.RootHash, update *ledger.TrieUpdate, err error)
Click to show internal directories.
Click to hide internal directories.