trie

package
v1.2.3-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TRIE_UNKNOW_NODE = byte(iota)
	TRIE_FULL_NODE
	TRIE_SHORT_NODE
	TRIE_VALUE_NODE
	TRIE_HASH_NODE
)

Variables

This section is empty.

Functions

func DeleteNodes

func DeleteNodes(db *leveldb.DB, hashList []types.Hash) error

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 NodeIterator

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

func NewNodeIterator

func NewNodeIterator(trie *Trie) *NodeIterator

func (*NodeIterator) Next

func (ni *NodeIterator) Next(deepInto func(*TrieNode) bool) bool

func (*NodeIterator) Node

func (ni *NodeIterator) Node() *TrieNode

type Trie

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

func NewTrie

func NewTrie(db *leveldb.DB, rootHash *types.Hash, pool *TrieNodePool) *Trie

func (*Trie) Copy

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

func (*Trie) Save

func (trie *Trie) Save(batch *leveldb.Batch) (successCallback func(), returnErr 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) AtomicComplete

func (trieNode *TrieNode) AtomicComplete(completeFunc func())

func (*TrieNode) Children

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

func (*TrieNode) Copy

func (trieNode *TrieNode) Copy(copyHash bool) *TrieNode

func (*TrieNode) DbDeserialize

func (trieNode *TrieNode) DbDeserialize(buf []byte) error

func (*TrieNode) DbSerialize

func (trieNode *TrieNode) DbSerialize() ([]byte, error)

func (*TrieNode) Hash

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

func (*TrieNode) IsLeafNode

func (trieNode *TrieNode) IsLeafNode() bool

func (*TrieNode) NodeType

func (trieNode *TrieNode) NodeType() byte

func (*TrieNode) SetChild

func (trieNode *TrieNode) SetChild(child *TrieNode)

func (*TrieNode) Value

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

type TrieNodePool

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

func NewCustomTrieNodePool

func NewCustomTrieNodePool(limit int, clearNum int) *TrieNodePool

func NewTrieNodePool

func NewTrieNodePool() *TrieNodePool

func (*TrieNodePool) Clear

func (pool *TrieNodePool) Clear()

func (*TrieNodePool) Get

func (pool *TrieNodePool) Get(key *types.Hash) *TrieNode

func (*TrieNodePool) Set

func (pool *TrieNodePool) Set(key *types.Hash, trieNode *TrieNode)

Jump to

Keyboard shortcuts

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