Documentation ¶
Index ¶
- Variables
- func GetFromDB(db chaindb.Database, root common.Hash, key []byte) ([]byte, error)
- type Hasher
- type Test
- type Trie
- func (t *Trie) ClearFromChild(keyToChild, key []byte) error
- func (t *Trie) ClearPrefix(prefix []byte)
- func (t *Trie) ClearPrefixFromDB(db chaindb.Database, prefix []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) DeleteFromDB(db chaindb.Database, key []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(db chaindb.Database, root common.Hash) error
- func (t *Trie) LoadFromMap(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) Put(key, value []byte)
- func (t *Trie) PutChild(keyToChild []byte, child *Trie) error
- func (t *Trie) PutInDB(db chaindb.Database, key, value []byte) error
- func (t *Trie) PutIntoChild(keyToChild, key, value []byte) error
- func (t *Trie) RootNode() node
- func (t *Trie) Snapshot() *Trie
- func (t *Trie) Store(db chaindb.Database) error
- func (t *Trie) String() string
- func (t *Trie) WriteDirty(db chaindb.Database) error
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 ¶
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) ClearPrefix ¶ added in v0.3.0
ClearPrefix deletes all key-value pairs from the trie where the key starts with the given prefix
func (*Trie) ClearPrefixFromDB ¶ added in v0.3.0
ClearPrefixFromDB deletes all keys with the given prefix from the trie and writes the updated nodes the database. Since it needs to write all the nodes from the changed node up to the root, it writes these in a batch operation.
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) DeleteFromDB ¶ added in v0.3.0
DeleteFromDB deletes a value from the trie and writes the updated nodes the database. Since it needs to write all the nodes from the changed node up to the root, it writes these in a batch operation.
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) Load ¶
Load reconstructs the trie from the database from the given root hash. Used when restarting the node to load the current state trie.
func (*Trie) LoadFromMap ¶ added in v0.3.0
LoadFromMap loads the given data into trie
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) PutChild ¶
PutChild inserts a child trie into the main trie at key :child_storage:[keyToChild]
func (*Trie) PutInDB ¶ added in v0.3.0
PutInDB puts a value into the trie and writes the updates nodes the database. Since it needs to write all the nodes from the changed node up to the root, it writes these in a batch operation.
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) Store ¶ added in v0.3.0
Store stores each trie node in the database, where the key is the hash of the encoded node and the value is the encoded node. Generally, this will only be used for the genesis trie.