diff options
author | Péter Szilágyi <peterke@gmail.com> | 2019-07-18 21:15:09 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-07-18 21:15:09 +0800 |
commit | 433cb564e9756553b4f5c8ca3834350b70e4e98d (patch) | |
tree | c943f7b124e703aea89b13b6ab76c5376b1d1e06 | |
parent | 8485f7cc7b1cb2f062e0bc50006f5a6841a8878f (diff) | |
download | go-tangerine-433cb564e9756553b4f5c8ca3834350b70e4e98d.tar go-tangerine-433cb564e9756553b4f5c8ca3834350b70e4e98d.tar.gz go-tangerine-433cb564e9756553b4f5c8ca3834350b70e4e98d.tar.bz2 go-tangerine-433cb564e9756553b4f5c8ca3834350b70e4e98d.tar.lz go-tangerine-433cb564e9756553b4f5c8ca3834350b70e4e98d.tar.xz go-tangerine-433cb564e9756553b4f5c8ca3834350b70e4e98d.tar.zst go-tangerine-433cb564e9756553b4f5c8ca3834350b70e4e98d.zip |
internal/ethapi: fix debug.chaindbProperty
-rw-r--r-- | internal/ethapi/api.go | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 338223fd5..04df794ec 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -44,7 +44,6 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" - "github.com/syndtr/goleveldb/leveldb" "github.com/tyler-smith/go-bip39" ) @@ -1633,22 +1632,18 @@ func NewPrivateDebugAPI(b Backend) *PrivateDebugAPI { return &PrivateDebugAPI{b: b} } -// ChaindbProperty returns leveldb properties of the chain database. +// ChaindbProperty returns leveldb properties of the key-value database. func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error) { - ldb, ok := api.b.ChainDb().(interface { - LDB() *leveldb.DB - }) - if !ok { - return "", fmt.Errorf("chaindbProperty does not work for memory databases") - } if property == "" { property = "leveldb.stats" } else if !strings.HasPrefix(property, "leveldb.") { property = "leveldb." + property } - return ldb.LDB().GetProperty(property) + return api.b.ChainDb().Stat(property) } +// ChaindbCompact flattens the entire key-value database into a single level, +// removing all unused slots and merging all keys. func (api *PrivateDebugAPI) ChaindbCompact() error { for b := byte(0); b < 255; b++ { log.Info("Compacting chain database", "range", fmt.Sprintf("0x%0.2X-0x%0.2X", b, b+1)) |