Skip to content

Commit a91dcf3

Browse files
authored
core/state: enable partial-functional reader (snapshot integration pt 3) (#30650)
It's a pull request based on #30643 In this pull request, the partial functional state reader is enabled if **legacy snapshot is not enabled**. The tracked flat states in pathdb will be used to serve the state retrievals, as the second implementation to fasten the state access. This pull request should be a noop change in normal cases.
1 parent a722adb commit a91dcf3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/state/database.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,19 @@ func (db *CachingDB) Reader(stateRoot common.Hash) (Reader, error) {
179179
// is optional and may be partially useful if it's not fully
180180
// generated.
181181
if db.snap != nil {
182+
// If standalone state snapshot is available (hash scheme),
183+
// then construct the legacy snap reader.
182184
snap := db.snap.Snapshot(stateRoot)
183185
if snap != nil {
184186
readers = append(readers, newFlatReader(snap))
185187
}
188+
} else {
189+
// If standalone state snapshot is not available, try to construct
190+
// the state reader with database.
191+
reader, err := db.triedb.StateReader(stateRoot)
192+
if err == nil {
193+
readers = append(readers, newFlatReader(reader)) // state reader is optional
194+
}
186195
}
187196
// Set up the trie reader, which is expected to always be available
188197
// as the gatekeeper unless the state is corrupted.

0 commit comments

Comments
 (0)