forked from cerc-io/plugeth
all: introduce trie owner notion (#24750)
* cmd, core/state, light, trie, eth: add trie owner notion * all: refactor * tests: fix goimports * core/state/snapshot: fix ineffasigns Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
co-authored by
Martin Holst Swende
parent
c375ee91e9
commit
22defa5af7
@@ -88,8 +88,8 @@ func makechain() (bc *core.BlockChain, addrHashes, txHashes []common.Hash) {
|
||||
}
|
||||
|
||||
func makeTries() (chtTrie *trie.Trie, bloomTrie *trie.Trie, chtKeys, bloomKeys [][]byte) {
|
||||
chtTrie, _ = trie.New(common.Hash{}, trie.NewDatabase(rawdb.NewMemoryDatabase()))
|
||||
bloomTrie, _ = trie.New(common.Hash{}, trie.NewDatabase(rawdb.NewMemoryDatabase()))
|
||||
chtTrie = trie.NewEmpty(trie.NewDatabase(rawdb.NewMemoryDatabase()))
|
||||
bloomTrie = trie.NewEmpty(trie.NewDatabase(rawdb.NewMemoryDatabase()))
|
||||
for i := 0; i < testChainLen; i++ {
|
||||
// The element in CHT is <big-endian block number> -> <block hash>
|
||||
key := make([]byte, 8)
|
||||
|
||||
@@ -62,7 +62,7 @@ func (f *fuzzer) readInt() uint64 {
|
||||
}
|
||||
|
||||
func (f *fuzzer) randomTrie(n int) (*trie.Trie, map[string]*kv) {
|
||||
trie, _ := trie.New(common.Hash{}, trie.NewDatabase(rawdb.NewMemoryDatabase()))
|
||||
trie := trie.NewEmpty(trie.NewDatabase(rawdb.NewMemoryDatabase()))
|
||||
vals := make(map[string]*kv)
|
||||
size := f.readInt()
|
||||
// Fill it with some fluff
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
"io"
|
||||
"sort"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"golang.org/x/crypto/sha3"
|
||||
@@ -144,7 +143,7 @@ func (f *fuzzer) fuzz() int {
|
||||
var (
|
||||
spongeA = &spongeDb{sponge: sha3.NewLegacyKeccak256()}
|
||||
dbA = trie.NewDatabase(spongeA)
|
||||
trieA, _ = trie.New(common.Hash{}, dbA)
|
||||
trieA = trie.NewEmpty(dbA)
|
||||
spongeB = &spongeDb{sponge: sha3.NewLegacyKeccak256()}
|
||||
trieB = trie.NewStackTrie(spongeB)
|
||||
vals kvs
|
||||
|
||||
@@ -144,7 +144,7 @@ func runRandTest(rt randTest) error {
|
||||
|
||||
triedb := trie.NewDatabase(memorydb.New())
|
||||
|
||||
tr, _ := trie.New(common.Hash{}, triedb)
|
||||
tr := trie.NewEmpty(triedb)
|
||||
values := make(map[string]string) // tracks content of the trie
|
||||
|
||||
for i, step := range rt {
|
||||
@@ -170,13 +170,13 @@ func runRandTest(rt randTest) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newtr, err := trie.New(hash, triedb)
|
||||
newtr, err := trie.New(common.Hash{}, hash, triedb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tr = newtr
|
||||
case opItercheckhash:
|
||||
checktr, _ := trie.New(common.Hash{}, triedb)
|
||||
checktr := trie.NewEmpty(triedb)
|
||||
it := trie.NewIterator(tr.NodeIterator(nil))
|
||||
for it.Next() {
|
||||
checktr.Update(it.Key, it.Value)
|
||||
|
||||
Reference in New Issue
Block a user