trie

package
v1.4.2-beta3 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownNode = byte(iota)
	FullNode
	ShortNode
	ValueNode
	HashNode
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

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

func NewIterator

func NewIterator(trie *Trie, prefix []byte) *Iterator

func (*Iterator) Next

func (iterator *Iterator) Next() (key, value []byte, ok bool)

type NodePool

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

func GetGlobalTriePool added in v1.4.0

func GetGlobalTriePool() *NodePool

func NewSimpleTrieNodePool

func NewSimpleTrieNodePool() *NodePool

func NewTrieNodePool

func NewTrieNodePool(limit int, clearNum int) *NodePool

func (*NodePool) Clear

func (p *NodePool) Clear()

func (*NodePool) Get

func (p *NodePool) Get(key *types.Hash) *TrieNode

func (*NodePool) Len added in v1.3.0

func (p *NodePool) Len() int

func (*NodePool) Set

func (p *NodePool) Set(key *types.Hash, trieNode *TrieNode)

type Trie

type Trie struct {
	Root *TrieNode
	// contains filtered or unexported fields
}

func NewTrie

func NewTrie(db storage.Store, rootHash *types.Hash, pool *NodePool) *Trie

func (*Trie) Clone

func (trie *Trie) Clone() *Trie

func (*Trie) GetValue

func (trie *Trie) GetValue(key []byte) []byte

func (*Trie) Hash

func (trie *Trie) Hash() *types.Hash

func (*Trie) LeafNodeValue

func (trie *Trie) LeafNodeValue(leafNode *TrieNode) []byte

func (*Trie) NewIterator

func (trie *Trie) NewIterator(prefix []byte) *Iterator

func (*Trie) NewNodeIterator

func (trie *Trie) NewNodeIterator(fn func(*TrieNode) bool) <-chan *TrieNode

func (*Trie) Remove added in v1.3.1

func (trie *Trie) Remove(batch ...storage.Batch) (err error)

func (*Trie) Save

func (trie *Trie) Save(batch ...storage.Batch) (fn func(), err error)

func (*Trie) SaveInTxn added in v1.2.3

func (trie *Trie) SaveInTxn(batch storage.Batch) (func(), error)

func (*Trie) SetValue

func (trie *Trie) SetValue(key []byte, value []byte)

type TrieNode

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

func NewFullNode

func NewFullNode(children map[byte]*TrieNode) *TrieNode

func NewHashNode

func NewHashNode(hash *types.Hash) *TrieNode

func NewShortNode

func NewShortNode(key []byte, child *TrieNode) *TrieNode

func NewValueNode

func NewValueNode(value []byte) *TrieNode

func (*TrieNode) Children

func (t *TrieNode) Children() map[byte]*TrieNode

func (*TrieNode) Clone

func (t *TrieNode) Clone(copyHash bool) *TrieNode

func (*TrieNode) Deserialize

func (t *TrieNode) Deserialize(buf []byte) error

func (*TrieNode) Hash

func (t *TrieNode) Hash() *types.Hash

func (*TrieNode) IsLeafNode

func (t *TrieNode) IsLeafNode() bool

func (*TrieNode) LeafCallback

func (t *TrieNode) LeafCallback(completeFunc func())

func (*TrieNode) NodeType

func (t *TrieNode) NodeType() byte

func (*TrieNode) Serialize

func (t *TrieNode) Serialize() ([]byte, error)

func (*TrieNode) SetChild

func (t *TrieNode) SetChild(child *TrieNode)

func (*TrieNode) SortedChildren added in v1.2.3

func (t *TrieNode) SortedChildren() []*TrieNode

func (*TrieNode) String

func (t *TrieNode) String() string

func (*TrieNode) Value

func (t *TrieNode) Value() []byte

Jump to

Keyboard shortcuts

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