pathdb

package
v0.15.21 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDiskLayerStale = errors.New("pathdb disk layer is stale")
	ErrMissingJournal = errors.New("journal is missing")
	ErrJournalCorrupt = errors.New("journal is corrupt")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	CleanCacheSize  uint64 // Maximum size (in bytes) for caching clean nodes
	WriteBufferSize int    // Maximum size (in bytes) for buffering writes before flushing
}

type DBJournal

type DBJournal struct {
	// TODO(weiihann): handle this, by right we should store the state root and verify when loading
	// root felt.StateRootHash
	Version   uint8
	EncLayers []byte // encoded bytes of layers
}

DBJournal represents the entire journal of the database. It contains the version of the journal format and the encoded sequence of layers that make up the state history.

type Database

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

Represents the path-based database which contains a in-memory layer tree (cache) + disk layer (database)

func New

func New(disk db.KeyValueStore, config *Config) (*Database, error)

Creates a new path-based database. It will load the journal from the disk and recreate the layer tree. If the journal is not found, it will create a new disk layer only. If the config is not provided, it will use the default config, which is 16MB for clean cache and 64MB for dirty cache.

func (*Database) Close

func (d *Database) Close() error

func (*Database) Commit

func (d *Database) Commit(root *felt.StateRootHash) error

Forces the commit of all the in-memory diff layers to the disk layer

func (*Database) Journal

func (d *Database) Journal(root *felt.StateRootHash) error

func (*Database) NewIterator

func (d *Database) NewIterator(id trieutils.TrieID) (db.Iterator, error)

TODO(weiihann): how to deal with state comm and the layer tree?

func (*Database) NodeReader

func (d *Database) NodeReader(id trieutils.TrieID) (database.NodeReader, error)

func (*Database) Scheme added in v0.15.15

func (d *Database) Scheme() database.TrieDBScheme

func (*Database) Update

func (d *Database) Update(
	root,
	parent *felt.StateRootHash,
	blockNum uint64,
	mergeClassNodes,
	mergeContractNodes *trienode.MergeNodeSet,
) error

Creates a new diff layer on top of the current layer tree. If the creation of the diff layer exceeds the given height of the layer tree, the bottom-most layer will be merged to the disk layer.

type DiffJournal

type DiffJournal struct {
	Root       felt.StateRootHash
	Block      uint64
	EncNodeset []byte // encoded bytes of nodeset
}

DiffJournal represents a single state transition layer containing changes to the trie. It stores the new state root, block number, and the encoded set of modified nodes.

type DiskJournal

type DiskJournal struct {
	Root       felt.StateRootHash
	ID         uint64
	EncNodeset []byte
}

DiskJournal represents a persisted state of the trie. It contains the state root, state ID, and the encoded set of all nodes at this state.

type JournalNodeSet

type JournalNodeSet struct {
	Nodes []journalNodes
}

Represents all the journal nodeset

Jump to

Keyboard shortcuts

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