forked from cerc-io/plugeth
internal/ethapi: add db operations to api (#24739)
Adds `debug_dbGet` method to rpc api
This commit is contained in:
@@ -19,6 +19,9 @@ package common
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
)
|
||||
|
||||
// FromHex returns the bytes represented by the hexadecimal string s.
|
||||
@@ -92,6 +95,15 @@ func Hex2BytesFixed(str string, flen int) []byte {
|
||||
return hh
|
||||
}
|
||||
|
||||
// ParseHexOrString tries to hexdecode b, but if the prefix is missing, it instead just returns the raw bytes
|
||||
func ParseHexOrString(str string) ([]byte, error) {
|
||||
b, err := hexutil.Decode(str)
|
||||
if errors.Is(err, hexutil.ErrMissingPrefix) {
|
||||
return []byte(str), nil
|
||||
}
|
||||
return b, err
|
||||
}
|
||||
|
||||
// RightPadBytes zero-pads slice to the right up to length l.
|
||||
func RightPadBytes(slice []byte, l int) []byte {
|
||||
if l <= len(slice) {
|
||||
|
||||
Reference in New Issue
Block a user