syncutils

package
v0.13.8-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: GPL-3.0, LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertTrieConsistency

func AssertTrieConsistency(t testing.TB, root common.Hash, a, b *trie.Database, onLeaf func(key, val []byte) error)

AssertTrieConsistency ensures given trieDB [a] and [b] both have the same non-empty trie at [root]. (all key/value pairs must be equal)

func CorruptTrie

func CorruptTrie(t *testing.T, diskdb ethdb.Batcher, tr *trie.Trie, n int)

CorruptTrie deletes every [n]th trie node from the trie given by [tr] from the underlying [db]. Assumes [tr] can be iterated without issue.

func FillAccounts

func FillAccounts(
	t *testing.T, trieDB *trie.Database, root common.Hash, numAccounts int,
	onAccount func(*testing.T, int, types.StateAccount) types.StateAccount,
) (common.Hash, map[*keystore.Key]*types.StateAccount)

FillAccounts adds [numAccounts] randomly generated accounts to the secure trie at [root] and commits it to [trieDB]. [onAccount] is called if non-nil (so the caller can modify the account before it is stored in the secure trie). returns the new trie root and a map of funded keys to StateAccount structs.

func FillTrie

func FillTrie(t *testing.T, numKeys int, keySize int, testTrie *trie.Trie) ([][]byte, [][]byte)

FillTrie fills a given trie with [numKeys] number of keys, each of size [keySize] returns inserted keys and values FillTrie reads from rand and the caller should call rand.Seed(n) for deterministic results

func GenerateTrie

func GenerateTrie(t *testing.T, trieDB *trie.Database, numKeys int, keySize int) (common.Hash, [][]byte, [][]byte)

GenerateTrie creates a trie with [numKeys] key-value pairs inside of [trieDB]. Returns the root of the generated trie, the slice of keys inserted into the trie in lexicographical order, and the slice of corresponding values. GenerateTrie reads from rand and the caller should call rand.Seed(n) for deterministic results

Types

type AccountIterator

type AccountIterator struct {
	snapshot.AccountIterator
	// contains filtered or unexported fields
}

AccountIterator wraps a snapshot.AccountIterator to conform to ethdb.Iterator accounts will be returned in consensus (FullRLP) format for compatibility with trie data.

func (*AccountIterator) Error

func (it *AccountIterator) Error() error

func (*AccountIterator) Key

func (it *AccountIterator) Key() []byte

func (*AccountIterator) Next

func (it *AccountIterator) Next() bool

func (*AccountIterator) Value

func (it *AccountIterator) Value() []byte

type StorageIterator

type StorageIterator struct {
	snapshot.StorageIterator
}

StorageIterator wraps a snapshot.StorageIterator to conform to ethdb.Iterator

func (*StorageIterator) Key

func (it *StorageIterator) Key() []byte

func (*StorageIterator) Value

func (it *StorageIterator) Value() []byte

Jump to

Keyboard shortcuts

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