loader

package
v0.31.14 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	TrieInitializer: FromScratch(),
	ExcludeHeight:   ExcludeNone(),
}

DefaultConfig sets the default configuration for the index loader. It is used when no options are specified.

Functions

This section is empty.

Types

type Checkpoint

type Checkpoint struct {
	// contains filtered or unexported fields
}

Checkpoint is a loader that loads a trie from a LedgerWAL checkpoint file.

func FromCheckpointFile

func FromCheckpointFile(filepath string, log *zerolog.Logger) *Checkpoint

FromCheckpointFile creates a loader which loads the trie from the provided reader, which should represent a LedgerWAL checkpoint file.

func (*Checkpoint) Trie

func (c *Checkpoint) Trie() (*trie.MTrie, error)

Trie loads the execution state trie from the LedgerWAL root checkpoint.

type Config

type Config struct {
	TrieInitializer mapper.Loader
	ExcludeHeight   func(uint64) bool
}

Config contains the configuration options for the index loader.

type Empty

type Empty struct {
}

Empty is a loader that loads as empty execution state trie.

func FromScratch

func FromScratch() *Empty

FromScratch creates a new loader which loads an empty execution state trie.

func (*Empty) Trie

func (e *Empty) Trie() (*trie.MTrie, error)

Trie returns a freshly initialized empty execution state trie.

type Exclude

type Exclude func(uint64) bool

Exclude is a function that returns true when a certain height should be excluded from the index trie restoration.

func ExcludeAtOrBelow

func ExcludeAtOrBelow(threshold uint64) Exclude

ExcludeAtOrBelow is an exclude function that ignores heights at or below the given threshold height. It can be used with the root height of a protocol state to avoid processing the root checkpoint registers during restore.

func ExcludeNone

func ExcludeNone() Exclude

ExcludeNone is an exclude function that processes all heights for index trie restoration.

type Option

type Option func(*Config)

Option is a configuration option for the index loader. It can be passed to the index loader's construction function to set optional parameters.

func WithExclude

func WithExclude(exclude Exclude) Option

WithExclude injects a function to ignore ledger register updates in the index database for certain heights when restoring the execution state trie. It can be used to exclude the root height during restoration from the index when the root checkpoint is loaded from disk directly.

func WithInitializer

func WithInitializer(load mapper.Loader) Option

WithInitializer injects an initializer for the execution state trie. It will be used to initialize the execution state trie that serves as basis for the restore. It can be used with the root checkpoint loader in order to load the initial root checkpoint from the loader instead of the index.

Jump to

Keyboard shortcuts

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