trie

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 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

func BeginsWith(a, b []byte) bool

func CompactDecode

func CompactDecode(str []byte) []byte

func CompactEncode

func CompactEncode(hexSlice []byte) []byte

func CompactHexDecode

func CompactHexDecode(str []byte) []byte

func CompareIntSlice

func CompareIntSlice(a, b []int) bool

Helper function for comparing slices

func DecodeCompact

func DecodeCompact(key []byte) []byte

func HasTerm

func HasTerm(s []byte) bool

func MatchingNibbleLength

func MatchingNibbleLength(a, b []byte) int

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

func RemTerm

func RemTerm(s []byte) []byte

Types

type Backend

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

type Cache

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

func NewCache

func NewCache(backend Backend) *Cache

func (*Cache) Copy

func (self *Cache) Copy() *Cache

func (*Cache) Flush

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

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

func (*Cache) Put

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

func (*Cache) Reset

func (self *Cache) Reset()

type FullNode

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

func NewFullNode

func NewFullNode(t *Trie) *FullNode

func (*FullNode) Branches

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

func (*FullNode) Copy

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

func (*FullNode) Dirty

func (self *FullNode) Dirty() bool

func (*FullNode) Hash

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

func (*FullNode) Len

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

Returns the length of non-nil nodes

func (*FullNode) RlpData

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

func (*FullNode) String

func (self *FullNode) String() string

func (*FullNode) Value

func (self *FullNode) Value() Node

type HashNode

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

func NewHash

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

func (*HashNode) Copy

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

func (*HashNode) Dirty

func (self *HashNode) Dirty() bool

func (*HashNode) Hash

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

func (*HashNode) RlpData

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

func (*HashNode) Value

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

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

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

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

func (*SecureTrie) Update

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

func (*SecureTrie) UpdateString

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

type ShortNode

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

func NewShortNode

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

func (*ShortNode) Copy

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

func (*ShortNode) Dirty

func (self *ShortNode) Dirty() bool

func (*ShortNode) Hash

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

func (*ShortNode) Key

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

func (*ShortNode) RlpData

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

func (*ShortNode) String

func (self *ShortNode) String() string

func (*ShortNode) Value

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

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

func (*Trie) Commit

func (self *Trie) Commit()

func (*Trie) Copy

func (self *Trie) Copy() *Trie

func (*Trie) Delete

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

func (*Trie) DeleteString

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

func (*Trie) Get

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

func (*Trie) GetString

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

func (*Trie) Hash

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

func (*Trie) Iterator

func (self *Trie) Iterator() *Iterator

func (*Trie) PrintRoot

func (self *Trie) PrintRoot()

func (*Trie) Reset

func (self *Trie) Reset()

Reset should only be called if the trie has been hashed

func (*Trie) Root

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

Legacy support

func (*Trie) Update

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

func (*Trie) UpdateString

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

type ValueNode

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

func NewValueNode

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

func (*ValueNode) Copy

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

func (*ValueNode) Dirty

func (self *ValueNode) Dirty() bool

func (*ValueNode) Hash

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

func (*ValueNode) RlpData

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

func (*ValueNode) String

func (self *ValueNode) String() string

Value node

func (*ValueNode) Val

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

func (*ValueNode) Value

func (self *ValueNode) Value() Node

Jump to

Keyboard shortcuts

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