Skip to content

Commit e8c9579

Browse files
authored
Merge pull request #19856 from karalabe/chaindb-property-fix
internal/ethapi: fix debug.chaindbProperty
2 parents 8485f7c + 433cb56 commit e8c9579

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

internal/ethapi/api.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import (
4444
"github.com/ethereum/go-ethereum/params"
4545
"github.com/ethereum/go-ethereum/rlp"
4646
"github.com/ethereum/go-ethereum/rpc"
47-
"github.com/syndtr/goleveldb/leveldb"
4847
"github.com/tyler-smith/go-bip39"
4948
)
5049

@@ -1633,22 +1632,18 @@ func NewPrivateDebugAPI(b Backend) *PrivateDebugAPI {
16331632
return &PrivateDebugAPI{b: b}
16341633
}
16351634

1636-
// ChaindbProperty returns leveldb properties of the chain database.
1635+
// ChaindbProperty returns leveldb properties of the key-value database.
16371636
func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error) {
1638-
ldb, ok := api.b.ChainDb().(interface {
1639-
LDB() *leveldb.DB
1640-
})
1641-
if !ok {
1642-
return "", fmt.Errorf("chaindbProperty does not work for memory databases")
1643-
}
16441637
if property == "" {
16451638
property = "leveldb.stats"
16461639
} else if !strings.HasPrefix(property, "leveldb.") {
16471640
property = "leveldb." + property
16481641
}
1649-
return ldb.LDB().GetProperty(property)
1642+
return api.b.ChainDb().Stat(property)
16501643
}
16511644

1645+
// ChaindbCompact flattens the entire key-value database into a single level,
1646+
// removing all unused slots and merging all keys.
16521647
func (api *PrivateDebugAPI) ChaindbCompact() error {
16531648
for b := byte(0); b < 255; b++ {
16541649
log.Info("Compacting chain database", "range", fmt.Sprintf("0x%0.2X-0x%0.2X", b, b+1))

0 commit comments

Comments
 (0)