tree

package
v0.73.0-preview.5 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDatabasesAreAlreadyInitialized    = errors.New("the databases are already initialized")
	ErrMinimumNumberOfSnapshotsToKeepIs1 = errors.New("the minimum number of snapshots to keep is 1")
)

Functions

This section is empty.

Types

type MetadataDatabase

type MetadataDatabase interface {
	Save(int64, *tmtypes.Snapshot) error
	Load(int64) (*tmtypes.Snapshot, error)
	Close() error
	Clear() error
	IsEmpty() bool
	FindVersionByBlockHeight(uint64) (int64, error)
	Delete(int64) error
	DeleteRange(fromVersion, toVersion int64) error
}

type Options

type Options func(t *Tree) error

func StartingAtBlockHeight

func StartingAtBlockHeight(blockHeight uint64) Options

func WithInMemoryDatabase

func WithInMemoryDatabase() Options

func WithLevelDBDatabase

func WithLevelDBDatabase(vegaPaths paths.Paths) Options

func WithMaxNumberOfSnapshotsToKeep

func WithMaxNumberOfSnapshotsToKeep(max uint64) Options

type SnapshotsDatabase

type SnapshotsDatabase interface {
	cometbftdb.DB
	Clear() error
}

type Tree

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

Tree is a high-level structure that abstract the management of the AVL away from the snapshot engine. It ensure the snapshot and metadata databases are in-sync, and old snapshots are removed when exceeding the maximum number to keep configured. When created, it will automatically remove old local snapshots and load the ones left. When the tree is no longer used, the resources it holds must be released by calling Release().

func New

func New(log *logging.Logger, opts ...Options) (*Tree, error)

func (*Tree) AddSnapshot

func (t *Tree) AddSnapshot(s *types.Snapshot) error

func (*Tree) AddState

func (t *Tree) AddState(key []byte, state []byte)

func (*Tree) AsPayloads

func (t *Tree) AsPayloads() ([]*types.Payload, error)

func (*Tree) FindImmutableTreeByHeight

func (t *Tree) FindImmutableTreeByHeight(blockHeight uint64) (*iavl.ImmutableTree, error)

func (*Tree) HasSnapshotsLoaded

func (t *Tree) HasSnapshotsLoaded() bool

func (*Tree) Hash

func (t *Tree) Hash() []byte

func (*Tree) ListLatestSnapshots

func (t *Tree) ListLatestSnapshots(maxLengthOfSnapshotList uint64) ([]*tmtypes.Snapshot, error)

func (*Tree) Release

func (t *Tree) Release()

func (*Tree) RemoveKey

func (t *Tree) RemoveKey(key []byte) bool

func (*Tree) SaveVersion

func (t *Tree) SaveVersion() error

func (*Tree) WorkingHash

func (t *Tree) WorkingHash() []byte

Jump to

Keyboard shortcuts

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