checkStateConsistency checks that all data of a state root is present.
(db database.Database, root common.Hash)
| 107 | |
| 108 | // checkStateConsistency checks that all data of a state root is present. |
| 109 | func 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. |
| 125 | func TestEmptyStateSync(t *testing.T) { |
no test coverage detected