storage

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TrieState

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

TrieState is a wrapper around a transient trie that is used during the course of executing some runtime call. If the execution of the call is successful, the trie will be saved in the StorageState.

func NewTrieState

func NewTrieState(state *trie.Trie) *TrieState

func (*TrieState) ClearChildStorage

func (t *TrieState) ClearChildStorage(keyToChild, key []byte) error

ClearChildStorage removes the child storage entry from the trie

func (*TrieState) ClearPrefix

func (t *TrieState) ClearPrefix(prefix []byte) (err error)

ClearPrefix deletes all key-value pairs from the trie where the key starts with the given prefix

func (*TrieState) ClearPrefixInChild

func (t *TrieState) ClearPrefixInChild(keyToChild, prefix []byte) error

ClearPrefixInChild clears all the keys from the child trie that have the given prefix

func (*TrieState) ClearPrefixInChildWithLimit added in v0.8.0

func (t *TrieState) ClearPrefixInChildWithLimit(keyToChild, prefix []byte, limit uint32) (uint32, bool, error)

func (*TrieState) ClearPrefixLimit added in v0.7.0

func (t *TrieState) ClearPrefixLimit(prefix []byte, limit uint32) (
	deleted uint32, allDeleted bool, err error)

ClearPrefixLimit deletes key-value pairs from the trie where the key starts with the given prefix till limit reached

func (*TrieState) CommitTransaction added in v0.9.0

func (t *TrieState) CommitTransaction()

Commit commits all storage changes made since StartTransaction was called.

func (*TrieState) Delete

func (t *TrieState) Delete(key []byte) (err error)

Delete deletes a key from the trie

func (*TrieState) DeleteChild added in v0.3.1

func (t *TrieState) DeleteChild(key []byte) (err error)

DeleteChild deletes a child trie from the main trie

func (*TrieState) DeleteChildLimit added in v0.7.0

func (t *TrieState) DeleteChildLimit(key []byte, limit *[]byte) (
	deleted uint32, allDeleted bool, err error)

DeleteChildLimit deletes up to limit of database entries by lexicographic order.

func (*TrieState) Get

func (t *TrieState) Get(key []byte) []byte

Get gets a value from the trie

func (*TrieState) GetChangedNodeHashes added in v0.7.0

func (t *TrieState) GetChangedNodeHashes() (inserted, deleted map[common.Hash]struct{}, err error)

GetChangedNodeHashes returns the two sets of hashes for all nodes inserted and deleted in the state trie since the last block produced (trie snapshot).

func (*TrieState) GetChild

func (t *TrieState) GetChild(keyToChild []byte) (*trie.Trie, error)

GetChild returns the child trie at the given key

func (*TrieState) GetChildNextKey

func (t *TrieState) GetChildNextKey(keyToChild, key []byte) ([]byte, error)

GetChildNextKey returns the next lexicographical larger key from child storage. If it does not exist, it returns nil.

func (*TrieState) GetChildStorage

func (t *TrieState) GetChildStorage(keyToChild, key []byte) ([]byte, error)

GetChildStorage returns a value from a child trie

func (*TrieState) GetKeysWithPrefixFromChild

func (t *TrieState) GetKeysWithPrefixFromChild(keyToChild, prefix []byte) ([][]byte, error)

GetKeysWithPrefixFromChild ...

func (*TrieState) Has

func (t *TrieState) Has(key []byte) bool

Has returns whether or not a key exists

func (*TrieState) LoadCode

func (t *TrieState) LoadCode() []byte

LoadCode returns the runtime code (located at :code)

func (*TrieState) LoadCodeHash

func (t *TrieState) LoadCodeHash() (common.Hash, error)

LoadCodeHash returns the hash of the runtime code (located at :code)

func (*TrieState) MustRoot

func (t *TrieState) MustRoot() common.Hash

MustRoot returns the trie's root hash. It panics if it fails to compute the root.

func (*TrieState) NextKey

func (t *TrieState) NextKey(key []byte) []byte

NextKey returns the next key in the trie in lexicographical order. If it does not exist, it returns nil.

func (*TrieState) Put added in v0.8.0

func (t *TrieState) Put(key, value []byte) (err error)

Put puts a key-value pair in the trie

func (*TrieState) RollbackTransaction added in v0.9.0

func (t *TrieState) RollbackTransaction()

Rollback rolls back all storage changes made since StartTransaction was called.

func (*TrieState) Root

func (t *TrieState) Root() (common.Hash, error)

Root returns the trie's root hash

func (*TrieState) SetChild

func (t *TrieState) SetChild(keyToChild []byte, child *trie.Trie) error

SetChild sets the child trie at the given key

func (*TrieState) SetChildStorage

func (t *TrieState) SetChildStorage(keyToChild, key, value []byte) error

SetChildStorage sets a key-value pair in a child trie

func (*TrieState) SetVersion added in v0.9.0

func (t *TrieState) SetVersion(v trie.TrieLayout)

func (*TrieState) Snapshot added in v0.3.1

func (t *TrieState) Snapshot() *trie.Trie

Snapshot creates a new "version" of the trie. The trie before Snapshot is called can no longer be modified, all further changes are on a new "version" of the trie. It returns the new version of the trie.

func (*TrieState) StartTransaction added in v0.9.0

func (t *TrieState) StartTransaction()

StartTransaction begins a new nested storage transaction which will either be committed or rolled back at a later time.

func (*TrieState) Trie

func (t *TrieState) Trie() *trie.Trie

Trie returns the TrieState's underlying trie

func (*TrieState) TrieEntries

func (t *TrieState) TrieEntries() map[string][]byte

TrieEntries returns every key-value pair in the trie

Jump to

Keyboard shortcuts

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