triedb/pathdb: improve err message in historical state reader (#32477)

Fixes https://github.com/ethereum/go-ethereum/issues/32474
This commit is contained in:
rjl493456442 2025-08-22 20:00:18 +08:00 committed by GitHub
parent 10421edf3e
commit ac1731907d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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.