wal

package
v0.12.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2020 License: AGPL-3.0 Imports: 21 Imported by: 13

Documentation

Index

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 EncodeDelete(rootHash ledger.RootHash) []byte

func EncodeUpdate

func EncodeUpdate(update *ledger.TrieUpdate) []byte

func LoadCheckpoint

func LoadCheckpoint(filepath string) (*flattener.FlattenedForest, error)

func NumberToFilename

func NumberToFilename(n int) string

func NumberToFilenamePart

func NumberToFilenamePart(n int) string

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

type Compactor struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewCompactor

func NewCompactor(checkpointer *Checkpointer, interval time.Duration, checkpointDistance uint) *Compactor

func (*Compactor) Done

func (c *Compactor) Done() <-chan struct{}

func (*Compactor) Ready

func (c *Compactor) Ready() <-chan struct{}

Ready periodically fires Run function, every `interval` If called more then once, behaviour is undefined.

func (*Compactor) Run

func (c *Compactor) Run() error

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) Close

func (w *LedgerWAL) Close() error

func (*LedgerWAL) NewCheckpointer

func (w *LedgerWAL) NewCheckpointer() (*Checkpointer, error)

NewCheckpointer returns a Checkpointer for this WAL

func (*LedgerWAL) RecordDelete

func (w *LedgerWAL) RecordDelete(rootHash ledger.RootHash) error

func (*LedgerWAL) RecordUpdate

func (w *LedgerWAL) RecordUpdate(update *ledger.TrieUpdate) error

func (*LedgerWAL) Replay

func (w *LedgerWAL) Replay(
	checkpointFn func(forestSequencing *flattener.FlattenedForest) error,
	updateFn func(update *ledger.TrieUpdate) error,
	deleteFn func(ledger.RootHash) error,
) error

func (*LedgerWAL) ReplayLogsOnly

func (w *LedgerWAL) ReplayLogsOnly(
	checkpointFn func(forestSequencing *flattener.FlattenedForest) error,
	updateFn func(update *ledger.TrieUpdate) error,
	deleteFn func(rootHash ledger.RootHash) error,
) error

func (*LedgerWAL) ReplayOnForest

func (w *LedgerWAL) ReplayOnForest(forest *mtrie.Forest) error

type SyncOnCloseFile

type SyncOnCloseFile struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL