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