triedb/pathdb: improve err message in historical state reader

This commit is contained in:
Gary Rong 2025-08-22 10:15:18 +08:00
parent 44fc0c8706
commit cc7dc67030

View file

@ -207,11 +207,11 @@ type HistoricalStateReader struct {
// HistoricReader constructs a reader for accessing the requested historic state.
func (db *Database) HistoricReader(root common.Hash) (*HistoricalStateReader, error) {
// Bail out if the state history hasn't been fully indexed
if db.indexer == nil || !db.indexer.inited() {
return nil, errors.New("state histories haven't been fully indexed yet")
if db.indexer == nil || db.freezer == nil {
return nil, fmt.Errorf("historical state %x is not available", root)
}
if db.freezer == nil {
return nil, errors.New("state histories are not available")
if !db.indexer.inited() {
return nil, errors.New("state histories haven't been fully indexed yet")
}
// States at the current disk layer or above are directly accessible via
// db.StateReader.