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

Function checkStateConsistency

core/state/sync_test.go:109–122  ·  view source on GitHub ↗

checkStateConsistency checks that all data of a state root is present.

(db database.Database, root common.Hash)

Source from the content-addressed store, hash-verified

107
108// checkStateConsistency checks that all data of a state root is present.
109func checkStateConsistency(db database.Database, root common.Hash) error {
110 // Create and iterate a state trie rooted in a sub-node
111 if _, err := db.Get(root.Bytes()); err != nil {
112 return nil // Consider a non existent state consistent.
113 }
114 state, err := New(root, NewDatabase(db))
115 if err != nil {
116 return err
117 }
118 it := NewNodeIterator(state)
119 for it.Next() {
120 }
121 return it.Error
122}
123
124// Tests that an empty state is not scheduled for syncing.
125func TestEmptyStateSync(t *testing.T) {

Callers 2

checkStateAccountsFunction · 0.85
TestIncompleteStateSyncFunction · 0.85

Calls 6

NextMethod · 0.95
NewDatabaseFunction · 0.85
NewNodeIteratorFunction · 0.85
NewFunction · 0.70
GetMethod · 0.65
BytesMethod · 0.65

Tested by

no test coverage detected