MCPcopy Create free account
hub / github.com/CPChain/chain / NewStateSync

Function NewStateSync

core/state/sync.go:28–41  ·  view source on GitHub ↗

NewStateSync create a new state trie download scheduler.

(root common.Hash, database trie.DatabaseReader)

Source from the content-addressed store, hash-verified

26
27// NewStateSync create a new state trie download scheduler.
28func NewStateSync(root common.Hash, database trie.DatabaseReader) *trie.Sync {
29 var syncer *trie.Sync
30 callback := func(leaf []byte, parent common.Hash) error {
31 var obj Account
32 if err := rlp.Decode(bytes.NewReader(leaf), &obj); err != nil {
33 return err
34 }
35 syncer.AddSubTrie(obj.Root, 64, parent, nil)
36 syncer.AddRawEntry(common.BytesToHash(obj.CodeHash), 64, parent)
37 return nil
38 }
39 syncer = trie.NewSync(root, database, callback)
40 return syncer
41}

Callers 6

TestEmptyStateSyncFunction · 0.85
testIterativeStateSyncFunction · 0.85
TestIncompleteStateSyncFunction · 0.85

Calls

no outgoing calls

Tested by 6

TestEmptyStateSyncFunction · 0.68
testIterativeStateSyncFunction · 0.68
TestIncompleteStateSyncFunction · 0.68