internal/ethapi: add db operations to api (#24739)

Adds `debug_dbGet` method to rpc api
This commit is contained in:
Sina Mahmoodi
2022-04-27 08:37:48 +02:00
committed by GitHub
parent a52bcccfe1
commit 16701c5169
4 changed files with 29 additions and 13 deletions
+12
View File
@@ -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) {