muxdb

package
v0.0.0-...-e4e12f0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package muxdb implements the storage layer for block-chain. It manages instance of merkle-patricia-trie, and general purpose named kv-store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MuxDB

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

MuxDB is the database to efficiently store state trie and block-chain data.

func NewMem

func NewMem() *MuxDB

NewMem creates a memory-backed DB.

func Open

func Open(path string, options *Options) (*MuxDB, error)

Open opens or creates DB at the given path.

func (*MuxDB) CleanTrieHistory

func (db *MuxDB) CleanTrieHistory(ctx context.Context, startCommitNum, limitCommitNum uint32) error

CleanTrieHistory clean trie history within [startCommitNum, limitCommitNum).

func (*MuxDB) Close

func (db *MuxDB) Close() error

Close closes the DB.

func (*MuxDB) IsNotFound

func (db *MuxDB) IsNotFound(err error) bool

IsNotFound returns if the error indicates key not found.

func (*MuxDB) NewNonCryptoTrie

func (db *MuxDB) NewNonCryptoTrie(name string, root workshare.Bytes32, commitNum, distinctNum uint32) *Trie

NewNonCryptoTrie creates non-crypto trie with existing root node.

If root is zero or blake2b hash of an empty string, the trie is initially empty.

func (*MuxDB) NewStore

func (db *MuxDB) NewStore(name string) kv.Store

NewStore creates named kv-store.

func (*MuxDB) NewTrie

func (db *MuxDB) NewTrie(name string, root workshare.Bytes32, commitNum, distinctNum uint32) *Trie

NewTrie creates trie with existing root node.

If root is zero or blake2b hash of an empty string, the trie is initially empty.

type Options

type Options struct {
	// TrieNodeCacheSizeMB is the size of the cache for trie node blobs.
	TrieNodeCacheSizeMB int
	// TrieRootCacheCapacity is the capacity of the cache for trie root nodes.
	TrieRootCacheCapacity int
	// TrieCachedNodeTTL defines the life time(times of commit) of cached trie nodes.
	TrieCachedNodeTTL uint16
	// TrieLeafBankSlotCapacity defines max count of cached slot for leaf bank.
	TrieLeafBankSlotCapacity int
	// 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 = trie.Trie

Trie is the managed trie.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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