mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
common, common/hexutil: use reflect.TypeFor (#32321)
This commit is contained in:
parent
dfde155541
commit
ec97ac7085
2 changed files with 8 additions and 8 deletions
|
|
@ -28,11 +28,11 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
bytesT = reflect.TypeOf(Bytes(nil))
|
||||
bigT = reflect.TypeOf((*Big)(nil))
|
||||
uintT = reflect.TypeOf(Uint(0))
|
||||
uint64T = reflect.TypeOf(Uint64(0))
|
||||
u256T = reflect.TypeOf((*uint256.Int)(nil))
|
||||
bytesT = reflect.TypeFor[Bytes]()
|
||||
bigT = reflect.TypeFor[*Big]()
|
||||
uintT = reflect.TypeFor[Uint]()
|
||||
uint64T = reflect.TypeFor[Uint64]()
|
||||
u256T = reflect.TypeFor[*uint256.Int]()
|
||||
)
|
||||
|
||||
// Bytes marshals/unmarshals as a JSON string with 0x prefix.
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
hashT = reflect.TypeOf(Hash{})
|
||||
addressT = reflect.TypeOf(Address{})
|
||||
hashT = reflect.TypeFor[Hash]()
|
||||
addressT = reflect.TypeFor[Address]()
|
||||
|
||||
// MaxAddress represents the maximum possible address value.
|
||||
MaxAddress = HexToAddress("0xffffffffffffffffffffffffffffffffffffffff")
|
||||
|
|
@ -466,7 +466,7 @@ func isString(input []byte) bool {
|
|||
// UnmarshalJSON parses a hash in hex syntax.
|
||||
func (d *Decimal) UnmarshalJSON(input []byte) error {
|
||||
if !isString(input) {
|
||||
return &json.UnmarshalTypeError{Value: "non-string", Type: reflect.TypeOf(uint64(0))}
|
||||
return &json.UnmarshalTypeError{Value: "non-string", Type: reflect.TypeFor[uint64]()}
|
||||
}
|
||||
if i, err := strconv.ParseUint(string(input[1:len(input)-1]), 10, 64); err == nil {
|
||||
*d = Decimal(i)
|
||||
|
|
|
|||
Loading…
Reference in a new issue