mptrie

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoData = errors.New("no data in hash node")

ErrNoData is an error when a hash node has no corresponding data

Functions

func DefaultHashFunc

func DefaultHashFunc(data []byte) []byte

DefaultHashFunc implements a default hash function

func New

func New(options ...Option) (trie.Trie, error)

New creates a trie with DB filename

func NewLeafIterator

func NewLeafIterator(tr trie.Trie) (trie.Iterator, error)

NewLeafIterator returns a new leaf iterator

func NewTwoLayerTrie

func NewTwoLayerTrie(dbForTrie trie.KVStore, rootKey string) trie.TwoLayerTrie

NewTwoLayerTrie creates a two layer trie

Types

type HashFunc

type HashFunc func([]byte) []byte

HashFunc defines a function to generate the hash which will be used as key in db

type LeafIterator

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

LeafIterator defines an iterator to go through all the leaves under given node

func (*LeafIterator) Next

func (li *LeafIterator) Next() ([]byte, []byte, error)

Next moves iterator to next node

type Option

type Option func(*merklePatriciaTrie) error

Option sets parameters for SameKeyLenTrieContext construction parameter

func AsyncOption

func AsyncOption() Option

AsyncOption enables async commit

func HashFuncOption

func HashFuncOption(hashFunc HashFunc) Option

HashFuncOption sets the hash func for the trie

func KVStoreOption

func KVStoreOption(kvStore trie.KVStore) Option

KVStoreOption sets the kvStore for the trie

func KeyLengthOption

func KeyLengthOption(len int) Option

KeyLengthOption sets the length of the keys saved in trie

func RootHashOption

func RootHashOption(h []byte) Option

RootHashOption sets the root hash for the trie

Jump to

Keyboard shortcuts

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