mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
Merge 025acb40ad into dcdd57df62
This commit is contained in:
commit
40c036c66a
2 changed files with 27 additions and 0 deletions
|
|
@ -1395,6 +1395,28 @@ func (api *PublicDebugAPI) GetBlockRlp(ctx context.Context, number uint64) (stri
|
|||
return fmt.Sprintf("%x", encoded), nil
|
||||
}
|
||||
|
||||
// GetLevelDbKey retrieves the value of a key from levelDB backend
|
||||
func (api *PublicDebugAPI) GetLevelDbKey(ctx context.Context, input string) (string, error) {
|
||||
ldb, ok := api.b.ChainDb().(interface {
|
||||
LDB() *leveldb.DB
|
||||
})
|
||||
if !ok {
|
||||
return "", fmt.Errorf("db not found!")
|
||||
}
|
||||
|
||||
bb, err := hexutil.Decode(input)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("incorrect input, expected string representation of hex")
|
||||
}
|
||||
|
||||
value, err := ldb.LDB().Get(bb, nil)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error getting value from levelDB %v", err)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%x", value), nil
|
||||
}
|
||||
|
||||
// PrintBlock retrieves a block and returns its pretty printed form.
|
||||
func (api *PublicDebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error) {
|
||||
block, _ := api.b.BlockByNumber(ctx, rpc.BlockNumber(number))
|
||||
|
|
|
|||
|
|
@ -191,6 +191,11 @@ web3._extend({
|
|||
call: 'debug_getBlockRlp',
|
||||
params: 1
|
||||
}),
|
||||
new web3._extend.Method({
|
||||
name: 'getLevelDbKey',
|
||||
call: 'debug_getLevelDbKey',
|
||||
params: 1
|
||||
}),
|
||||
new web3._extend.Method({
|
||||
name: 'setHead',
|
||||
call: 'debug_setHead',
|
||||
|
|
|
|||
Loading…
Reference in a new issue