trie

package
v0.0.0-...-508c5de Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: LGPL-2.1-or-later Imports: 8 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 EmptyStringSlice

func EmptyStringSlice(l int) []interface{}

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 Cache

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

func NewCache

func NewCache(db ethutil.Database) *Cache

func (*Cache) Commit

func (cache *Cache) Commit()

func (*Cache) Delete

func (cache *Cache) Delete(key []byte)

func (*Cache) Get

func (cache *Cache) Get(key []byte) *ethutil.Value

func (*Cache) Len

func (s *Cache) Len() int

func (*Cache) Put

func (cache *Cache) Put(v interface{}) interface{}

func (*Cache) PutValue

func (cache *Cache) PutValue(v interface{}, force bool) interface{}

func (*Cache) Undo

func (cache *Cache) Undo()

type EachCallback

type EachCallback func(key string, node *ethutil.Value)

type Iterator

type Iterator struct {
	Path [][]byte

	Key   []byte
	Value *ethutil.Value
	// contains filtered or unexported fields
}

func NewIterator

func NewIterator(trie *Trie) *Iterator

func (*Iterator) Next

func (self *Iterator) Next(key string) []byte

Get the next in keys

type Node

type Node struct {
	Key   []byte
	Value *ethutil.Value
	Dirty bool
}

func NewNode

func NewNode(key []byte, val *ethutil.Value, dirty bool) *Node

func (*Node) Copy

func (n *Node) Copy() *Node

type NodeType

type NodeType byte
const (
	EmptyNode NodeType = iota
	BranchNode
	LeafNode
	ExtNode
)

type StateObject

type StateObject interface {
	State() *Trie
	Sync()
	Undo()
}

TODO A StateObject is an object that has a state root This is goig to be the object for the second level caching (the caching of object which have a state such as contracts)

type Trie

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

A (modified) Radix Trie implementation. The Trie implements a caching mechanism and will used cached values if they are present. If a node is not present in the cache it will try to fetch it from the database and store the cached value. Please note that the data isn't persisted unless `Sync` is explicitly called.

func New

func New(db ethutil.Database, Root interface{}) *Trie

func ParanoiaCheck

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

func (*Trie) Cache

func (t *Trie) Cache() *Cache

func (*Trie) Cmp

func (t *Trie) Cmp(trie *Trie) bool

Simple compare function which creates a rlp value out of the evaluated objects

func (*Trie) Copy

func (t *Trie) Copy() *Trie

Returns a copy of this trie

func (*Trie) Delete

func (t *Trie) Delete(key string)

func (*Trie) Get

func (t *Trie) Get(key string) string

func (*Trie) GetRoot

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

func (*Trie) InsertState

func (t *Trie) InsertState(node interface{}, key []byte, value interface{}) interface{}

func (*Trie) Iterator

func (self *Trie) Iterator() *Iterator

func (*Trie) NewIterator

func (t *Trie) NewIterator() *TrieIterator

func (*Trie) Put

func (t *Trie) Put(node interface{}) interface{}

func (*Trie) Sync

func (t *Trie) Sync()

Save the cached value to the database.

func (*Trie) Undo

func (t *Trie) Undo()

func (*Trie) Update

func (t *Trie) Update(key, value string)

func (*Trie) UpdateState

func (t *Trie) UpdateState(node interface{}, key []byte, value string) interface{}

type TrieIterator

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

func (*TrieIterator) Collect

func (it *TrieIterator) Collect() [][]byte

func (*TrieIterator) Each

func (it *TrieIterator) Each(cb EachCallback)

func (*TrieIterator) Key

func (it *TrieIterator) Key() string

func (*TrieIterator) Purge

func (it *TrieIterator) Purge() int

func (*TrieIterator) Value

func (it *TrieIterator) Value() string

Jump to

Keyboard shortcuts

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