trie

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2019 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 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) 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 db.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) Save

func (trie *Trie) Save() (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() *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) 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