mptrie

package
v2.1.0-rc16 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 13 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 CloseLogDB

func CloseLogDB() error

CloseLogDB close the log DB file

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

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

func OpenLogDB

func OpenLogDB(dbPath string) error

OpenLogDB open the log DB file

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

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

SortedList is a data structure where elements are in ascending order

func NewSortedList

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

NewSortedList create SortedList from keys in the children map

func (*SortedList) Clone

func (sl *SortedList) Clone() *SortedList

Clone clones a sorted list

func (*SortedList) Delete

func (sl *SortedList) Delete(key uint8)

Delete deletes key in the sortedlist

func (*SortedList) Insert

func (sl *SortedList) Insert(key uint8)

Insert insert key into sortedlist

func (*SortedList) List

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