Documentation ¶
Overview ¶
Package muxdb implements the storage layer for block-chain. It manages instance of merkle-patricia-trie, and general purpose named kv-store.
Package muxdb implements the storage layer for block-chain. It manages instance of merkle-patricia-trie, and general purpose named kv-store.
Index ¶
- type Cache
- type MuxDB
- func (db *MuxDB) Close() error
- func (db *MuxDB) DeleteTrieHistoryNodes(ctx context.Context, startMajorVer, limitMajorVer uint32) error
- func (db *MuxDB) EnableMetrics()
- func (db *MuxDB) IsNotFound(err error) bool
- func (db *MuxDB) NewStore(name string) kv.Store
- func (db *MuxDB) NewTrie(name string, root trie.Root) *Trie
- type Options
- type Trie
- func (t *Trie) Checkpoint(ctx context.Context, baseMajorVer uint32, handleLeaf func(*trie.Leaf)) error
- func (t *Trie) Commit(newVer trie.Version, skipHash bool) error
- func (t *Trie) Copy() *Trie
- func (t *Trie) Get(key []byte) ([]byte, []byte, error)
- func (t *Trie) Hash() thor.Bytes32
- func (t *Trie) NodeIterator(start []byte, baseMajorVer uint32) trie.NodeIterator
- func (t *Trie) SetNoFillCache(b bool)
- func (t *Trie) Update(key, val, meta []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶ added in v2.2.0
type Cache interface { AddNodeBlob(keyBuf *[]byte, name string, path []byte, ver trie.Version, blob []byte, isCommitting bool) GetNodeBlob(keyBuf *[]byte, name string, path []byte, ver trie.Version, peek bool) []byte AddRootNode(name string, n trie.Node) GetRootNode(name string, ver trie.Version) trie.Node }
type MuxDB ¶
type MuxDB struct {
// contains filtered or unexported fields
}
MuxDB is the database to efficiently store state trie and block-chain data.
func (*MuxDB) DeleteTrieHistoryNodes ¶ added in v2.2.0
func (db *MuxDB) DeleteTrieHistoryNodes(ctx context.Context, startMajorVer, limitMajorVer uint32) error
DeleteTrieHistoryNodes deletes trie history nodes within partitions of [startMajorVer, limitMajorVer).
func (*MuxDB) EnableMetrics ¶ added in v2.2.0
func (db *MuxDB) EnableMetrics()
func (*MuxDB) IsNotFound ¶
IsNotFound returns if the error indicates key not found.
type Options ¶
type Options struct { // TrieNodeCacheSizeMB is the size of the cache for trie node blobs. TrieNodeCacheSizeMB int // TrieCachedNodeTTL defines the life time(times of commit) of cached trie nodes. TrieCachedNodeTTL uint16 // TrieHistPartitionFactor is the partition factor for historical trie nodes. TrieHistPartitionFactor uint32 // TrieDedupedPartitionFactor is the partition factor for deduped trie nodes. TrieDedupedPartitionFactor uint32 // TrieWillCleanHistory is the hint to tell if historical nodes will be cleaned. TrieWillCleanHistory bool // OpenFilesCacheCapacity is the capacity of open files caching for underlying database. OpenFilesCacheCapacity int // ReadCacheMB is the size of read cache for underlying database. ReadCacheMB int // WriteBufferMB is the size of write buffer for underlying database. WriteBufferMB int }
Options optional parameters for MuxDB.
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
Trie is the managed trie.
func (*Trie) Checkpoint ¶ added in v2.2.0
func (t *Trie) Checkpoint(ctx context.Context, baseMajorVer uint32, handleLeaf func(*trie.Leaf)) error
Checkpoint transfers standalone nodes, whose major version within [baseMajorVer, thisMajorVer], into deduped space.
func (*Trie) Commit ¶ added in v2.2.0
Commit writes all nodes to the trie's database.
Committing flushes nodes from memory. Subsequent Get calls will load nodes from the database. If skipHash is true, less disk space is taken up but crypto features of merkle trie lost.
func (*Trie) Get ¶ added in v2.2.0
Get returns the value for key stored in the trie. The value bytes must not be modified by the caller.
func (*Trie) NodeIterator ¶ added in v2.2.0
func (t *Trie) NodeIterator(start []byte, baseMajorVer uint32) trie.NodeIterator
NodeIterator returns an iterator that returns nodes of the trie. Iteration starts at the key after the given start key
func (*Trie) SetNoFillCache ¶ added in v2.2.0
SetNoFillCache enable or disable cache filling.
func (*Trie) Update ¶ added in v2.2.0
Update associates key with value in the trie. Subsequent calls to Get will return value. If value has length zero, any existing value is deleted from the trie and calls to Get will return nil.
The value bytes must not be modified by the caller while they are stored in the trie.