Skip to content

Commit 0914ec0

Browse files
committed
core, eth, les, trie: rework snap sync
1 parent ae8ce72 commit 0914ec0

File tree

12 files changed

+864
-509
lines changed

12 files changed

+864
-509
lines changed

core/state/statedb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) {
940940
// The onleaf func is called _serially_, so we can reuse the same account
941941
// for unmarshalling every time.
942942
var account types.StateAccount
943-
root, accountCommitted, err := s.trie.Commit(func(_ [][]byte, _ []byte, leaf []byte, parent common.Hash) error {
943+
root, accountCommitted, err := s.trie.Commit(func(_ [][]byte, _ []byte, leaf []byte, parent common.Hash, _ []byte) error {
944944
if err := rlp.DecodeBytes(leaf, &account); err != nil {
945945
return nil
946946
}

core/state/sync.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,29 @@ import (
2727
)
2828

2929
// NewStateSync create a new state trie download scheduler.
30-
func NewStateSync(root common.Hash, database ethdb.KeyValueReader, onLeaf func(paths [][]byte, leaf []byte) error) *trie.Sync {
30+
func NewStateSync(root common.Hash, database ethdb.KeyValueReader, onLeaf func(keys [][]byte, leaf []byte) error) *trie.Sync {
3131
// Register the storage slot callback if the external callback is specified.
32-
var onSlot func(paths [][]byte, hexpath []byte, leaf []byte, parent common.Hash) error
32+
var onSlot func(keys [][]byte, path []byte, leaf []byte, parent common.Hash, parentPath []byte) error
3333
if onLeaf != nil {
34-
onSlot = func(paths [][]byte, hexpath []byte, leaf []byte, parent common.Hash) error {
35-
return onLeaf(paths, leaf)
34+
onSlot = func(keys [][]byte, path []byte, leaf []byte, parent common.Hash, parentPath []byte) error {
35+
return onLeaf(keys, leaf)
3636
}
3737
}
3838
// Register the account callback to connect the state trie and the storage
3939
// trie belongs to the contract.
4040
var syncer *trie.Sync
41-
onAccount := func(paths [][]byte, hexpath []byte, leaf []byte, parent common.Hash) error {
41+
onAccount := func(keys [][]byte, path []byte, leaf []byte, parent common.Hash, parentPath []byte) error {
4242
if onLeaf != nil {
43-
if err := onLeaf(paths, leaf); err != nil {
43+
if err := onLeaf(keys, leaf); err != nil {
4444
return err
4545
}
4646
}
4747
var obj types.StateAccount
4848
if err := rlp.Decode(bytes.NewReader(leaf), &obj); err != nil {
4949
return err
5050
}
51-
syncer.AddSubTrie(obj.Root, hexpath, parent, onSlot)
52-
syncer.AddCodeEntry(common.BytesToHash(obj.CodeHash), hexpath, parent)
51+
syncer.AddSubTrie(obj.Root, path, parent, parentPath, onSlot)
52+
syncer.AddCodeEntry(common.BytesToHash(obj.CodeHash), path, parent, parentPath)
5353
return nil
5454
}
5555
syncer = trie.NewSync(root, database, onAccount)

0 commit comments

Comments
 (0)