syncutils

package
v0.6.9-rc.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: GPL-3.0, LGPL-3.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertTrieConsistency added in v0.5.11

func AssertTrieConsistency(t testing.TB, root common.Hash, a, b *triedb.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 added in v0.5.11

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 added in v0.5.11

func FillAccounts(
	t *testing.T, trieDB *triedb.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 added in v0.5.11

func FillTrie(t *testing.T, start, numKeys int, keySize int, trieDB *triedb.Database, root common.Hash) (common.Hash, [][]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 added in v0.5.11

func GenerateTrie(t *testing.T, trieDB *triedb.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