Documentation
¶
Index ¶
- Variables
- type Hasher
- type Test
- type Trie
- func (t *Trie) ClearFromChild(keyToChild, key []byte) error
- func (t *Trie) Decode(enc []byte) error
- func (t *Trie) DeepCopy() (*Trie, error)
- func (t *Trie) Delete(key []byte) error
- func (t *Trie) DeleteFromChild(keyToChild []byte) error
- func (t *Trie) Encode() ([]byte, error)
- func (t *Trie) EncodeRoot() ([]byte, error)
- func (t *Trie) Entries() map[string][]byte
- func (t *Trie) Get(key []byte) (value []byte, err error)
- func (t *Trie) GetChild(keyToChild []byte) (*Trie, error)
- func (t *Trie) GetFromChild(keyToChild, key []byte) ([]byte, error)
- func (t *Trie) GetKeysWithPrefix(prefix []byte) [][]byte
- func (t *Trie) Hash() (common.Hash, error)
- func (t *Trie) Load(data map[string]string) error
- func (t *Trie) MustHash() common.Hash
- func (t *Trie) NextKey(key []byte) []byte
- func (t *Trie) Print()
- func (t *Trie) PrintEncoding()
- func (t *Trie) Put(key, value []byte) error
- func (t *Trie) PutChild(keyToChild []byte, child *Trie) error
- func (t *Trie) PutIntoChild(keyToChild, key, value []byte) error
- func (t *Trie) RootNode() node
- func (t *Trie) String() string
- func (t *Trie) StringWithEncoding() string
Constants ¶
This section is empty.
Variables ¶
var ChildStorageKeyPrefix = []byte(":child_storage:default:")
ChildStorageKeyPrefix is the prefix for all child storage keys
var EmptyHash, _ = NewEmptyTrie().Hash()
nolint
Functions ¶
This section is empty.
Types ¶
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher is a wrapper around a hash function
type Test ¶
type Test struct {
// contains filtered or unexported fields
}
Test represents a key-value pair for a test
func GenerateRandomTests ¶
GenerateRandomTests returns an array of random Tests
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
Trie is a Merkle Patricia Trie. The zero value is an empty trie with no database. Use NewTrie to create a trie that sits on top of a database.
func (*Trie) ClearFromChild ¶ added in v0.2.0
ClearFromChild removes the child storage entry
func (*Trie) Decode ¶
Decode decodes a trie from the DB and sets the receiver to it The encoded trie must have been encoded with t.Encode
func (*Trie) DeepCopy ¶ added in v0.2.0
DeepCopy makes a new trie and copies over the existing trie into the new trie
func (*Trie) DeleteFromChild ¶ added in v0.2.0
DeleteFromChild deletes from child storage
func (*Trie) Encode ¶
Encode traverses the trie recursively, encodes each node, SCALE encodes the encoded node, and appends them all together
func (*Trie) EncodeRoot ¶
EncodeRoot returns the encoded root of the trie
func (*Trie) Entries ¶
Entries returns all the key-value pairs in the trie as a map of keys to values
func (*Trie) GetFromChild ¶
GetFromChild retrieves a key-value pair from the child trie located in the main trie at key :child_storage:[keyToChild]
func (*Trie) GetKeysWithPrefix ¶ added in v0.2.0
GetKeysWithPrefix returns all keys in the trie that have the given prefix
func (*Trie) MustHash ¶ added in v0.2.0
MustHash returns the hashed root of the trie. It panics if it fails to hash the root node.
func (*Trie) NextKey ¶ added in v0.2.0
NextKey returns the next key in the trie in lexicographic order. It returns nil if there is no next key
func (*Trie) PrintEncoding ¶
func (t *Trie) PrintEncoding()
PrintEncoding prints the trie with node encodings through pre-order traversal
func (*Trie) PutChild ¶
PutChild inserts a child trie into the main trie at key :child_storage:[keyToChild]
func (*Trie) PutIntoChild ¶
PutIntoChild puts a key-value pair into the child trie located in the main trie at key :child_storage:[keyToChild]
func (*Trie) StringWithEncoding ¶
StringWithEncoding returns the trie stringified as well as the encoding of each node