Documentation
¶
Index ¶
- Variables
- type Config
- type DBJournal
- type Database
- func (d *Database) Close() error
- func (d *Database) Commit(root *felt.StateRootHash) error
- func (d *Database) Journal(root *felt.StateRootHash) error
- func (d *Database) NewIterator(id trieutils.TrieID) (db.Iterator, error)
- func (d *Database) NodeReader(id trieutils.TrieID) (database.NodeReader, error)
- func (d *Database) Scheme() database.TrieDBScheme
- func (d *Database) Update(root, parent *felt.StateRootHash, blockNum uint64, ...) error
- type DiffJournal
- type DiskJournal
- type JournalNodeSet
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
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) 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) NewIterator ¶
TODO(weiihann): how to deal with state comm and the layer tree?
func (*Database) NodeReader ¶
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