diff --git a/core/rawdb/accessors_state.go b/core/rawdb/accessors_state.go index bc726d911b..adc77fae83 100644 --- a/core/rawdb/accessors_state.go +++ b/core/rawdb/accessors_state.go @@ -27,7 +27,11 @@ import ( // ReadPreimage retrieves a single preimage of the provided hash. func ReadPreimage(db ethdb.KeyValueReader, hash common.Hash) []byte { data, _ := db.Get(preimageKey(hash)) - preimageMissCounter.Inc(1) + if len(data) == 0 { + preimageMissCounter.Inc(1) + } else { + preimageHitsCounter.Inc(1) + } return data } diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index 48451447ab..5480c7a72c 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -146,6 +146,7 @@ var ( SyncCommitteeKey = []byte("committee-") // bigEndian64(syncPeriod) -> serialized committee preimageCounter = metrics.NewRegisteredCounter("db/preimage/total", nil) + preimageHitsCounter = metrics.NewRegisteredCounter("db/preimage/hits", nil) preimageMissCounter = metrics.NewRegisteredCounter("db/preimage/miss", nil) )