mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-31 16:21:21 +00:00
common: remove ToHex and ToHexArray (#21610)
ToHex was deprecated a couple years ago. The last remaining use was in ToHexArray, which itself only had a single call site. This just moves ToHexArray near its only remaining call site and implements it using hexutil.Encode. This changes the default behaviour of ToHexArray and with it the behaviour of eth_getProof. Previously we encoded an empty slice as 0, now the empty slice is encoded as 0x. # Conflicts: # common/bytes.go # internal/ethapi/api.go
This commit is contained in:
parent
0a48344dfe
commit
4f2558be98
@ -18,31 +18,9 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
// ToHex returns the hex representation of b, prefixed with '0x'.
|
||||
// For empty slices, the return value is "0x0".
|
||||
//
|
||||
// Deprecated: use hexutil.Encode instead.
|
||||
func ToHex(b []byte) string {
|
||||
hex := Bytes2Hex(b)
|
||||
if len(hex) == 0 {
|
||||
hex = "0"
|
||||
}
|
||||
return "0x" + hex
|
||||
}
|
||||
|
||||
// ToHexArray creates a array of hex-string based on []byte
|
||||
func ToHexArray(b [][]byte) []string {
|
||||
r := make([]string, len(b))
|
||||
for i := range b {
|
||||
r[i] = ToHex(b[i])
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// FromHex returns the bytes represented by the hexadecimal string s.
|
||||
// s may be prefixed with "0x".
|
||||
func FromHex(s string) []byte {
|
||||
|
@ -1890,3 +1890,12 @@ func checkTxFee(gasPrice *big.Int, gas uint64, cap float64) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// toHexSlice creates a slice of hex-strings based on []byte.
|
||||
func toHexSlice(b [][]byte) []string {
|
||||
r := make([]string, len(b))
|
||||
for i := range b {
|
||||
r[i] = hexutil.Encode(b[i])
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user