eth: add chaindbProperty to debug API
This commit is contained in:
parent
05e257c22c
commit
bcd8aeefdd
18
eth/api.go
18
eth/api.go
@ -26,6 +26,7 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
"github.com/syndtr/goleveldb/leveldb"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1566,6 +1568,22 @@ func NewPrivateDebugAPI(config *core.ChainConfig, eth *Ethereum) *PrivateDebugAP
|
|||||||
return &PrivateDebugAPI{config: config, eth: eth}
|
return &PrivateDebugAPI{config: config, eth: eth}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChaindbProperty returns leveldb properties of the chain database.
|
||||||
|
func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error) {
|
||||||
|
ldb, ok := api.eth.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)
|
||||||
|
}
|
||||||
|
|
||||||
// BlockTraceResults is the returned value when replaying a block to check for
|
// BlockTraceResults is the returned value when replaying a block to check for
|
||||||
// consensus results and full VM trace logs for all included transactions.
|
// consensus results and full VM trace logs for all included transactions.
|
||||||
type BlockTraceResult struct {
|
type BlockTraceResult struct {
|
||||||
|
@ -295,6 +295,12 @@ web3._extend({
|
|||||||
call: 'debug_dumpBlock',
|
call: 'debug_dumpBlock',
|
||||||
params: 1
|
params: 1
|
||||||
}),
|
}),
|
||||||
|
new web3._extend.Method({
|
||||||
|
name: 'chaindbProperty',
|
||||||
|
call: 'debug_chaindbProperty',
|
||||||
|
params: 1,
|
||||||
|
outputFormatter: console.log
|
||||||
|
}),
|
||||||
new web3._extend.Method({
|
new web3._extend.Method({
|
||||||
name: 'metrics',
|
name: 'metrics',
|
||||||
call: 'debug_metrics',
|
call: 'debug_metrics',
|
||||||
|
Loading…
Reference in New Issue
Block a user