mptrie

package
v1.8.4-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 10 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 NewLayerTwoLeafIterator added in v1.8.0

func NewLayerTwoLeafIterator(tr trie.TwoLayerTrie, layerOneKey []byte, l int) (trie.Iterator, error)

NewLayerTwoLeafIterator returns a new leaf iterator

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

type SortedList added in v1.7.1

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

SortedList is a data structure where elements are in ascending order

func NewSortedList added in v1.7.1

func NewSortedList(children map[byte]node) *SortedList

NewSortedList create SortedList from keys in the children map

func (*SortedList) Delete added in v1.7.1

func (sl *SortedList) Delete(key uint8)

Delete deletes key in the sortedlist

func (*SortedList) Insert added in v1.7.1

func (sl *SortedList) Insert(key uint8)

Insert insert key into sortedlist

func (*SortedList) List added in v1.7.1

func (sl *SortedList) List() []uint8

List returns sorted indices

Jump to

Keyboard shortcuts

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