storage

package
v0.0.0-...-c69f244 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: LGPL-3.0 Imports: 5 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(t *trie.Trie) (*TrieState, error)

NewTrieState returns a new TrieState with the given trie

func (*TrieState) BeginStorageTransaction

func (s *TrieState) BeginStorageTransaction()

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

func (*TrieState) ClearChildStorage

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

ClearChildStorage removes the child storage entry from the trie

func (*TrieState) ClearPrefix

func (s *TrieState) ClearPrefix(prefix []byte) error

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

func (*TrieState) ClearPrefixInChild

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

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

func (*TrieState) ClearPrefixLimit

func (s *TrieState) ClearPrefixLimit(prefix []byte, limit uint32) (uint32, bool)

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

func (*TrieState) CommitStorageTransaction

func (s *TrieState) CommitStorageTransaction()

CommitStorageTransaction commits all storage changes made since BeginStorageTransaction was called.

func (*TrieState) Delete

func (s *TrieState) Delete(key []byte)

Delete deletes a key from the trie

func (*TrieState) DeleteChild

func (s *TrieState) DeleteChild(key []byte)

DeleteChild deletes a child trie from the main trie

func (*TrieState) DeleteChildLimit

func (s *TrieState) DeleteChildLimit(key []byte, limit *[]byte) (uint32, bool, error)

DeleteChildLimit deletes up to limit of database entries by lexicographic order, return number

deleted, true if all delete otherwise false

func (*TrieState) Get

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

Get gets a value from the trie

func (*TrieState) GetChild

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

GetChild returns the child trie at the given key

func (*TrieState) GetChildNextKey

func (s *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 (s *TrieState) GetChildStorage(keyToChild, key []byte) ([]byte, error)

GetChildStorage returns a value from a child trie

func (*TrieState) GetDeletedNodeHashes

func (s *TrieState) GetDeletedNodeHashes() (hashesSet map[common.Hash]struct{})

GetDeletedNodeHashes returns the hash of nodes that were deleted from the state trie since the last block produced.

func (*TrieState) GetInsertedNodeHashes

func (s *TrieState) GetInsertedNodeHashes() (hashesSet map[common.Hash]struct{}, err error)

GetInsertedNodeHashes returns a set of hashes of all nodes that were inserted into state trie since the last block produced.

func (*TrieState) GetKeysWithPrefixFromChild

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

GetKeysWithPrefixFromChild ...

func (*TrieState) Has

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

Has returns whether or not a key exists

func (*TrieState) LoadCode

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

LoadCode returns the runtime code (located at :code)

func (*TrieState) LoadCodeHash

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

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

func (*TrieState) MustRoot

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

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

func (*TrieState) NextKey

func (s *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) RollbackStorageTransaction

func (s *TrieState) RollbackStorageTransaction()

RollbackStorageTransaction rolls back all storage changes made since BeginStorageTransaction was called.

func (*TrieState) Root

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

Root returns the trie's root hash

func (*TrieState) Set

func (s *TrieState) Set(key, value []byte)

Set sets a key-value pair in the trie

func (*TrieState) SetChild

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

SetChild sets the child trie at the given key

func (*TrieState) SetChildStorage

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

SetChildStorage sets a key-value pair in a child trie

func (*TrieState) Snapshot

func (s *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) Trie

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

Trie returns the TrieState's underlying trie

func (*TrieState) TrieEntries

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