triedb/pathdb: update comment

This commit is contained in:
Gary Rong 2025-05-29 15:22:34 +08:00
parent f7ae5b6513
commit c428df2a6a
3 changed files with 18 additions and 3 deletions

View file

@ -479,6 +479,9 @@ func (i *historyIndexer) close() {
i.initer.close() i.initer.close()
} }
// inited returns a flag indicating whether the existing state histories
// have been fully indexed, in other words, whether they are available
// for external access.
func (i *historyIndexer) inited() bool { func (i *historyIndexer) inited() bool {
return i.initer.inited() return i.initer.inited()
} }

View file

@ -311,7 +311,8 @@ func (r *historyReader) read(state stateIdentQuery, stateID uint64, lastID uint6
lastIndexedID := rawdb.ReadLastStateHistoryIndex(r.disk) lastIndexedID := rawdb.ReadLastStateHistoryIndex(r.disk)
// To serve the request, all state histories from stateID+1 to lastID // To serve the request, all state histories from stateID+1 to lastID
// must be indexed // must be indexed. It's not supposed to happen unless system is very
// wrong.
if lastIndexedID == nil || *lastIndexedID < lastID { if lastIndexedID == nil || *lastIndexedID < lastID {
indexed := "null" indexed := "null"
if lastIndexedID != nil { if lastIndexedID != nil {

View file

@ -210,8 +210,19 @@ func (db *Database) HistoricReader(root common.Hash) (*HistoricalStateReader, er
if db.indexer == nil || !db.indexer.inited() { if db.indexer == nil || !db.indexer.inited() {
return nil, errors.New("state histories haven't been fully indexed yet") return nil, errors.New("state histories haven't been fully indexed yet")
} }
// States older than current disk layer (disk layer is included) are available if db.freezer == nil {
// for accessing. return nil, errors.New("state histories are not available")
}
// States at the current disk layer or above are directly accessible via
// db.StateReader.
//
// States older than the current disk layer (including the disk layer
// itself) are available through historic state access.
//
// Note: the requested state may refer to a stale historic state that has
// already been pruned. This function does not validate availability, as
// underlying states may be pruned dynamically. Validity is checked during
// each actual state retrieval.
id := rawdb.ReadStateID(db.diskdb, root) id := rawdb.ReadStateID(db.diskdb, root)
if id == nil { if id == nil {
return nil, fmt.Errorf("state %#x is not available", root) return nil, fmt.Errorf("state %#x is not available", root)