trie

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2015 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package trie implements Merkle Patricia Tries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginsWith added in v0.9.39

func BeginsWith(a, b []byte) bool

func CompactDecode added in v0.9.39

func CompactDecode(str []byte) []byte

func CompactEncode added in v0.9.39

func CompactEncode(hexSlice []byte) []byte

func CompactHexDecode added in v0.9.39

func CompactHexDecode(str []byte) []byte

func CompareIntSlice added in v0.9.39

func CompareIntSlice(a, b []int) bool

Helper function for comparing slices

func DecodeCompact added in v0.9.39

func DecodeCompact(key []byte) []byte

func HasTerm added in v0.9.39

func HasTerm(s []byte) bool

func MatchingNibbleLength added in v0.9.39

func MatchingNibbleLength(a, b []byte) int

Returns the amount of nibbles that match each other from 0 ...

func RemTerm added in v0.9.39

func RemTerm(s []byte) []byte

Types

type Backend added in v0.9.39

type Backend interface {
	Get([]byte) ([]byte, error)
	Put([]byte, []byte) error
}

type Cache added in v0.9.39

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

func NewCache added in v0.9.39

func NewCache(backend Backend) *Cache

func (*Cache) Copy added in v0.9.39

func (self *Cache) Copy() *Cache

func (*Cache) Flush added in v0.9.39

func (self *Cache) Flush()

Flush flushes the trie to the backing layer. If this is a leveldb instance we'll use a batched write, otherwise we'll use regular put.

func (*Cache) Get added in v0.9.39

func (self *Cache) Get(key []byte) []byte

func (*Cache) Put added in v0.9.39

func (self *Cache) Put(key []byte, data []byte)

func (*Cache) Reset added in v0.9.39

func (self *Cache) Reset()

type FullNode added in v0.9.39

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

func NewFullNode added in v0.9.39

func NewFullNode(t *Trie) *FullNode

func (*FullNode) Branches added in v0.9.39

func (self *FullNode) Branches() []Node

func (*FullNode) Copy added in v0.9.39

func (self *FullNode) Copy(t *Trie) Node

func (*FullNode) Dirty added in v0.9.39

func (self *FullNode) Dirty() bool

func (*FullNode) Hash added in v0.9.39

func (self *FullNode) Hash() interface{}

func (*FullNode) Len added in v0.9.39

func (self *FullNode) Len() (amount int)

Returns the length of non-nil nodes

func (*FullNode) RlpData added in v0.9.39

func (self *FullNode) RlpData() interface{}

func (*FullNode) String added in v0.9.39

func (self *FullNode) String() string

func (*FullNode) Value added in v0.9.39

func (self *FullNode) Value() Node

type HashNode added in v0.9.39

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

func NewHash added in v0.9.39

func NewHash(key []byte, trie *Trie) *HashNode

func (*HashNode) Copy added in v0.9.39

func (self *HashNode) Copy(t *Trie) Node

func (*HashNode) Dirty added in v0.9.39

func (self *HashNode) Dirty() bool

func (*HashNode) Hash added in v0.9.39

func (self *HashNode) Hash() interface{}

func (*HashNode) RlpData added in v0.9.39

func (self *HashNode) RlpData() interface{}

func (*HashNode) Value added in v0.9.39

func (self *HashNode) Value() Node

These methods will never be called but we have to satisfy Node interface

type Iterator

type Iterator struct {
	Key   []byte
	Value []byte
	// contains filtered or unexported fields
}

func NewIterator

func NewIterator(trie *Trie) *Iterator

func (*Iterator) Next

func (self *Iterator) Next() bool

type Node added in v0.9.39

type Node interface {
	Value() Node
	Copy(*Trie) Node // All nodes, for now, return them self
	Dirty() bool

	Hash() interface{}
	RlpData() interface{}
	// contains filtered or unexported methods
}

type SecureTrie

type SecureTrie struct {
	*Trie
}

func NewSecure

func NewSecure(root []byte, backend Backend) *SecureTrie

func (*SecureTrie) Copy

func (self *SecureTrie) Copy() *SecureTrie

func (*SecureTrie) Delete

func (self *SecureTrie) Delete(key []byte) Node

func (*SecureTrie) DeleteString added in v0.9.39

func (self *SecureTrie) DeleteString(key string) Node

func (*SecureTrie) Get

func (self *SecureTrie) Get(key []byte) []byte

func (*SecureTrie) GetKey

func (self *SecureTrie) GetKey(shaKey []byte) []byte

func (*SecureTrie) GetString added in v0.9.39

func (self *SecureTrie) GetString(key string) []byte

func (*SecureTrie) Update

func (self *SecureTrie) Update(key, value []byte) Node

func (*SecureTrie) UpdateString added in v0.9.39

func (self *SecureTrie) UpdateString(key, value string) Node

type ShortNode added in v0.9.39

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

func NewShortNode added in v0.9.39

func NewShortNode(t *Trie, key []byte, value Node) *ShortNode

func (*ShortNode) Copy added in v0.9.39

func (self *ShortNode) Copy(t *Trie) Node

func (*ShortNode) Dirty added in v0.9.39

func (self *ShortNode) Dirty() bool

func (*ShortNode) Hash added in v0.9.39

func (self *ShortNode) Hash() interface{}

func (*ShortNode) Key added in v0.9.39

func (self *ShortNode) Key() []byte

func (*ShortNode) RlpData added in v0.9.39

func (self *ShortNode) RlpData() interface{}

func (*ShortNode) String added in v0.9.39

func (self *ShortNode) String() string

func (*ShortNode) Value added in v0.9.39

func (self *ShortNode) Value() Node

type Trie

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

func New

func New(root []byte, backend Backend) *Trie

func ParanoiaCheck added in v0.9.39

func ParanoiaCheck(t1 *Trie, backend Backend) (bool, *Trie)

func (*Trie) Commit

func (self *Trie) Commit()

func (*Trie) Copy added in v0.9.39

func (self *Trie) Copy() *Trie

func (*Trie) Delete

func (self *Trie) Delete(key []byte) Node

func (*Trie) DeleteString added in v0.9.39

func (self *Trie) DeleteString(key string) Node

func (*Trie) Get

func (self *Trie) Get(key []byte) []byte

func (*Trie) GetString added in v0.9.39

func (self *Trie) GetString(key string) []byte

func (*Trie) Hash

func (self *Trie) Hash() []byte

func (*Trie) Iterator added in v0.9.39

func (self *Trie) Iterator() *Iterator

func (*Trie) PrintRoot added in v0.9.39

func (self *Trie) PrintRoot()

func (*Trie) Reset added in v0.9.39

func (self *Trie) Reset()

Reset should only be called if the trie has been hashed

func (*Trie) Root added in v0.9.39

func (self *Trie) Root() []byte

Legacy support

func (*Trie) Update

func (self *Trie) Update(key, value []byte) Node

func (*Trie) UpdateString added in v0.9.39

func (self *Trie) UpdateString(key, value string) Node

type ValueNode added in v0.9.39

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

func NewValueNode added in v0.9.39

func NewValueNode(trie *Trie, data []byte) *ValueNode

func (*ValueNode) Copy added in v0.9.39

func (self *ValueNode) Copy(t *Trie) Node

func (*ValueNode) Dirty added in v0.9.39

func (self *ValueNode) Dirty() bool

func (*ValueNode) Hash added in v0.9.39

func (self *ValueNode) Hash() interface{}

func (*ValueNode) RlpData added in v0.9.39

func (self *ValueNode) RlpData() interface{}

func (*ValueNode) String added in v0.9.39

func (self *ValueNode) String() string

Value node

func (*ValueNode) Val added in v0.9.39

func (self *ValueNode) Val() []byte

func (*ValueNode) Value added in v0.9.39

func (self *ValueNode) Value() Node

Jump to

Keyboard shortcuts

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