ethdb, internal/ethapi: support exposing Pebble stats too, beside LevelDB (#28224)

ethdb, internal/ethapi: support exposing Pebble stats too, besinde LevelDB
pull/28226/head
Péter Szilágyi 1 year ago committed by GitHub
parent b9450bfcca
commit f988b2332e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      ethdb/leveldb/leveldb.go
  2. 7
      ethdb/pebble/pebble.go
  3. 5
      internal/ethapi/api.go

@ -22,6 +22,7 @@ package leveldb
import (
"fmt"
"strings"
"sync"
"time"
@ -245,6 +246,11 @@ func (db *Database) NewSnapshot() (ethdb.Snapshot, error) {
// Stat returns a particular internal stat of the database.
func (db *Database) Stat(property string) (string, error) {
if property == "" {
property = "leveldb.stats"
} else if !strings.HasPrefix(property, "leveldb.") {
property = "leveldb." + property
}
return db.db.GetProperty(property)
}

@ -379,9 +379,12 @@ func upperBound(prefix []byte) (limit []byte) {
return limit
}
// Stat returns a particular internal stat of the database.
// Stat returns the internal metrics of Pebble in a text format. It's a developer
// method to read everything there is to read independent of Pebble version.
//
// The property is unused in Pebble as there's only one thing to retrieve.
func (d *Database) Stat(property string) (string, error) {
return "", nil
return d.db.Metrics().String(), nil
}
// Compact flattens the underlying data store for the given key range. In essence,

@ -2191,11 +2191,6 @@ func (api *DebugAPI) PrintBlock(ctx context.Context, number uint64) (string, err
// ChaindbProperty returns leveldb properties of the key-value database.
func (api *DebugAPI) ChaindbProperty(property string) (string, error) {
if property == "" {
property = "leveldb.stats"
} else if !strings.HasPrefix(property, "leveldb.") {
property = "leveldb." + property
}
return api.b.ChainDb().Stat(property)
}

Loading…
Cancel
Save