trie

package
v0.8.6-0...-0fd6a22 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2015 License: LGPL-2.1-or-later Imports: 9 Imported by: 0

Documentation

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 string) []byte

func CompactEncode

func CompactEncode(hexSlice []byte) string

func CompactHexDecode

func CompactHexDecode(str string) []byte

func CompareIntSlice

func CompareIntSlice(a, b []int) bool

Helper function for comparing slices

func DecodeCompact

func DecodeCompact(key []byte) string

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)
}

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()

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 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 (*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