gofmt -w -r 'interface {} -> any' .

This commit is contained in:
cuiweixie 2026-01-07 15:35:28 +08:00
parent 127d1f42bb
commit f506aa1c27
198 changed files with 836 additions and 836 deletions

View file

@ -60,7 +60,7 @@ func JSON(reader io.Reader) (ABI, error) {
// of 4 bytes and arguments are all 32 bytes.
// Method ids are created from the first 4 bytes of the hash of the
// methods string signature. (signature = baz(uint32,string32))
func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
func (abi ABI) Pack(name string, args ...any) ([]byte, error) {
// Fetch the ABI of the requested method
if name == "" {
// constructor
@ -105,7 +105,7 @@ func (abi ABI) getArguments(name string, data []byte) (Arguments, error) {
}
// Unpack unpacks the output according to the abi specification.
func (abi ABI) Unpack(name string, data []byte) ([]interface{}, error) {
func (abi ABI) Unpack(name string, data []byte) ([]any, error) {
args, err := abi.getArguments(name, data)
if err != nil {
return nil, err
@ -116,7 +116,7 @@ func (abi ABI) Unpack(name string, data []byte) ([]interface{}, error) {
// UnpackIntoInterface unpacks the output in v according to the abi specification.
// It performs an additional copy. Please only use, if you want to unpack into a
// structure that does not strictly conform to the abi structure (e.g. has additional arguments)
func (abi ABI) UnpackIntoInterface(v interface{}, name string, data []byte) error {
func (abi ABI) UnpackIntoInterface(v any, name string, data []byte) error {
args, err := abi.getArguments(name, data)
if err != nil {
return err
@ -129,7 +129,7 @@ func (abi ABI) UnpackIntoInterface(v interface{}, name string, data []byte) erro
}
// UnpackIntoMap unpacks a log into the provided map[string]interface{}.
func (abi ABI) UnpackIntoMap(v map[string]interface{}, name string, data []byte) (err error) {
func (abi ABI) UnpackIntoMap(v map[string]any, name string, data []byte) (err error) {
args, err := abi.getArguments(name, data)
if err != nil {
return err

View file

@ -839,8 +839,8 @@ func TestUnpackEventIntoMap(t *testing.T) {
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
}
receivedMap := map[string]interface{}{}
expectedReceivedMap := map[string]interface{}{
receivedMap := map[string]any{}
expectedReceivedMap := map[string]any{
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
"memo": []byte{88},
@ -861,7 +861,7 @@ func TestUnpackEventIntoMap(t *testing.T) {
t.Error("unpacked `received` map does not match expected map")
}
receivedAddrMap := map[string]interface{}{}
receivedAddrMap := map[string]any{}
if err = abi.UnpackIntoMap(receivedAddrMap, "receivedAddr", data); err != nil {
t.Error(err)
}
@ -890,7 +890,7 @@ func TestUnpackMethodIntoMap(t *testing.T) {
}
// Tests a method with no outputs
receiveMap := map[string]interface{}{}
receiveMap := map[string]any{}
if err = abi.UnpackIntoMap(receiveMap, "receive", data); err != nil {
t.Error(err)
}
@ -899,7 +899,7 @@ func TestUnpackMethodIntoMap(t *testing.T) {
}
// Tests a method with only outputs
sendMap := map[string]interface{}{}
sendMap := map[string]any{}
if err = abi.UnpackIntoMap(sendMap, "send", data); err != nil {
t.Error(err)
}
@ -911,7 +911,7 @@ func TestUnpackMethodIntoMap(t *testing.T) {
}
// Tests a method with outputs and inputs
getMap := map[string]interface{}{}
getMap := map[string]any{}
if err = abi.UnpackIntoMap(getMap, "get", data); err != nil {
t.Error(err)
}
@ -940,7 +940,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) {
if len(data)%32 == 0 {
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
}
getMap := map[string]interface{}{}
getMap := map[string]any{}
if err = abi.UnpackIntoMap(getMap, "get", data); err == nil {
t.Error("naming conflict between two methods; error expected")
}
@ -959,7 +959,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) {
if len(data)%32 == 0 {
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
}
receivedMap := map[string]interface{}{}
receivedMap := map[string]any{}
if err = abi.UnpackIntoMap(receivedMap, "received", data); err != nil {
t.Error("naming conflict between two events; no error expected")
}
@ -986,7 +986,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) {
if len(data)%32 == 0 {
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
}
expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
"memo": []byte{88},

View file

@ -61,7 +61,7 @@ var (
"bytes32", "bytes"}
)
func unpackPack(abi ABI, method string, input []byte) ([]interface{}, bool) {
func unpackPack(abi ABI, method string, input []byte) ([]any, bool) {
if out, err := abi.Unpack(method, input); err == nil {
_, err := abi.Pack(method, out...)
if err != nil {
@ -77,7 +77,7 @@ func unpackPack(abi ABI, method string, input []byte) ([]interface{}, bool) {
return nil, false
}
func packUnpack(abi ABI, method string, input *[]interface{}) bool {
func packUnpack(abi ABI, method string, input *[]any) bool {
if packed, err := abi.Pack(method, input); err == nil {
outptr := reflect.New(reflect.TypeOf(input))
err := abi.UnpackIntoInterface(outptr.Interface(), method, packed)

View file

@ -279,7 +279,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
}
buffer := new(bytes.Buffer)
funcs := map[string]interface{}{
funcs := map[string]any{
"bindtype": bindType,
"bindtopictype": bindTopicType,
"capitalise": abi.ToCamelCase,

View file

@ -352,7 +352,7 @@ func BindV2(types []string, abis []string, bytecodes []string, pkg string, libs
}
}
buffer := new(bytes.Buffer)
funcs := map[string]interface{}{
funcs := map[string]any{
"bindtype": bindType,
"bindtopictype": bindTopicType,
"capitalise": abi.ToCamelCase,

View file

@ -226,7 +226,7 @@ func NewBoundContract(address common.Address, abi abi.ABI, caller ContractCaller
return bind2.NewBoundContract(address, abi, caller, transactor, filterer)
}
func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend ContractBackend, params ...interface{}) (common.Address, *types.Transaction, *BoundContract, error) {
func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend ContractBackend, params ...any) (common.Address, *types.Transaction, *BoundContract, error) {
packed, err := abi.Pack("", params...)
if err != nil {
return common.Address{}, nil, nil, err

View file

@ -199,7 +199,7 @@ func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) {
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"name": hash,
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
@ -216,7 +216,7 @@ func TestUnpackAnonymousLogIntoMap(t *testing.T) {
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
var received map[string]interface{}
var received map[string]any
err := bc.UnpackLogIntoMap(received, "received", mockLog)
if err == nil {
t.Error("unpacking anonymous event is not supported")
@ -243,7 +243,7 @@ func TestUnpackIndexedSliceTyLogIntoMap(t *testing.T) {
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"names": hash,
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
@ -269,7 +269,7 @@ func TestUnpackIndexedArrayTyLogIntoMap(t *testing.T) {
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"addresses": hash,
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
@ -296,7 +296,7 @@ func TestUnpackIndexedFuncTyLogIntoMap(t *testing.T) {
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"function": functionTy,
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
@ -319,7 +319,7 @@ func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) {
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"content": hash,
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
@ -374,8 +374,8 @@ func TestTransactGasFee(t *testing.T) {
assert.True(mt.suggestGasPriceCalled)
}
func unpackAndCheck(t *testing.T, bc *bind.BoundContract, expected map[string]interface{}, mockLog types.Log) {
received := make(map[string]interface{})
func unpackAndCheck(t *testing.T, bc *bind.BoundContract, expected map[string]any, mockLog types.Log) {
received := make(map[string]any)
if err := bc.UnpackLogIntoMap(received, "received", mockLog); err != nil {
t.Error(err)
}
@ -411,7 +411,7 @@ func TestCall(t *testing.T) {
name, method string
opts *bind.CallOpts
mc bind.ContractCaller
results *[]interface{}
results *[]any
wantErr bool
wantErrExact error
}{{
@ -547,7 +547,7 @@ func TestCall(t *testing.T) {
codeAtBytes: []byte{0},
},
method: method,
results: &[]interface{}{0},
results: &[]any{0},
wantErr: true,
}}
for _, test := range tests {

View file

@ -81,7 +81,7 @@ func (e Error) String() string {
return e.str
}
func (e *Error) Unpack(data []byte) (interface{}, error) {
func (e *Error) Unpack(data []byte) (any, error) {
if len(data) < 4 {
return "", fmt.Errorf("insufficient data for unpacking: have %d, want at least 4", len(data))
}

View file

@ -85,6 +85,6 @@ func typeCheck(t Type, value reflect.Value) error {
}
// typeErr returns a formatted type casting error.
func typeErr(expected, got interface{}) error {
func typeErr(expected, got any) error {
return fmt.Errorf("abi: cannot use %v as type %v as argument", got, expected)
}

View file

@ -215,8 +215,8 @@ func TestEventTupleUnpack(t *testing.T) {
addr := common.HexToAddress("0x00Ce0d46d924CC8437c806721496599FC3FFA268")
var testCases = []struct {
data string
dest interface{}
expected interface{}
dest any
expected any
jsonLog []byte
error string
name string
@ -229,8 +229,8 @@ func TestEventTupleUnpack(t *testing.T) {
"Can unpack ERC20 Transfer event into structure",
}, {
transferData1,
&[]interface{}{&bigint},
&[]interface{}{&bigintExpected},
&[]any{&bigint},
&[]any{&bigintExpected},
jsonEventTransfer,
"",
"Can unpack ERC20 Transfer event into slice",
@ -274,8 +274,8 @@ func TestEventTupleUnpack(t *testing.T) {
"Can unpack Pledge event into structure",
}, {
pledgeData1,
&[]interface{}{&common.Address{}, &bigint, &[3]byte{}},
&[]interface{}{
&[]any{&common.Address{}, &bigint, &[3]byte{}},
&[]any{
&addr,
&bigintExpected2,
&[3]byte{'u', 's', 'd'}},
@ -284,8 +284,8 @@ func TestEventTupleUnpack(t *testing.T) {
"Can unpack Pledge event into slice",
}, {
pledgeData1,
&[3]interface{}{&common.Address{}, &bigint, &[3]byte{}},
&[3]interface{}{
&[3]any{&common.Address{}, &bigint, &[3]byte{}},
&[3]any{
&addr,
&bigintExpected2,
&[3]byte{'u', 's', 'd'}},
@ -294,8 +294,8 @@ func TestEventTupleUnpack(t *testing.T) {
"Can unpack Pledge event into an array",
}, {
pledgeData1,
&[]interface{}{new(int), 0, 0},
&[]interface{}{},
&[]any{new(int), 0, 0},
&[]any{},
jsonEventPledge,
"abi: cannot unmarshal common.Address in to int",
"Can not unpack Pledge event into slice with wrong types",
@ -308,15 +308,15 @@ func TestEventTupleUnpack(t *testing.T) {
"Can not unpack Pledge event into struct with wrong filed types",
}, {
pledgeData1,
&[]interface{}{common.Address{}, new(big.Int)},
&[]interface{}{},
&[]any{common.Address{}, new(big.Int)},
&[]any{},
jsonEventPledge,
"abi: insufficient number of arguments for unpack, want 3, got 2",
"Can not unpack Pledge event into too short slice",
}, {
pledgeData1,
new(map[string]interface{}),
&[]interface{}{},
new(map[string]any),
&[]any{},
jsonEventPledge,
"abi:[2] cannot unmarshal tuple in to map[string]interface {}",
"Can not unpack Pledge event into map",
@ -343,7 +343,7 @@ func TestEventTupleUnpack(t *testing.T) {
}
}
func unpackTestEventData(dest interface{}, hexData string, jsonEvent []byte, assert *assert.Assertions) error {
func unpackTestEventData(dest any, hexData string, jsonEvent []byte, assert *assert.Assertions) error {
data, err := hex.DecodeString(hexData)
assert.NoError(err, "Hex data should be a correct hex-string")
var e Event

View file

@ -24,7 +24,7 @@ import (
type packUnpackTest struct {
def string
unpacked interface{}
unpacked any
packed string
}

View file

@ -38,7 +38,7 @@ import (
// into:
//
// type TupleT struct { X *big.Int }
func ConvertType(in interface{}, proto interface{}) interface{} {
func ConvertType(in any, proto any) any {
protoType := reflect.TypeOf(proto)
if reflect.TypeOf(in).ConvertibleTo(protoType) {
return reflect.ValueOf(in).Convert(protoType).Interface()

View file

@ -25,7 +25,7 @@ import (
type reflectTest struct {
name string
args []string
struc interface{}
struc any
want map[string]string
err string
}

View file

@ -84,7 +84,7 @@ func parseElementaryType(unescapedSelector string) (string, string, error) {
return parsedType, rest, nil
}
func parseCompositeType(unescapedSelector string) ([]interface{}, string, error) {
func parseCompositeType(unescapedSelector string) ([]any, string, error) {
if len(unescapedSelector) == 0 || unescapedSelector[0] != '(' {
return nil, "", fmt.Errorf("expected '(', got %c", unescapedSelector[0])
}
@ -92,7 +92,7 @@ func parseCompositeType(unescapedSelector string) ([]interface{}, string, error)
if err != nil {
return nil, "", fmt.Errorf("failed to parse type: %v", err)
}
result := []interface{}{parsedType}
result := []any{parsedType}
for len(rest) > 0 && rest[0] != ')' {
parsedType, rest, err = parseType(rest[1:])
if err != nil {
@ -109,7 +109,7 @@ func parseCompositeType(unescapedSelector string) ([]interface{}, string, error)
return result, rest[1:], nil
}
func parseType(unescapedSelector string) (interface{}, string, error) {
func parseType(unescapedSelector string) (any, string, error) {
if len(unescapedSelector) == 0 {
return nil, "", errors.New("empty type")
}
@ -120,14 +120,14 @@ func parseType(unescapedSelector string) (interface{}, string, error) {
}
}
func assembleArgs(args []interface{}) ([]ArgumentMarshaling, error) {
func assembleArgs(args []any) ([]ArgumentMarshaling, error) {
arguments := make([]ArgumentMarshaling, 0)
for i, arg := range args {
// generate dummy name to avoid unmarshal issues
name := fmt.Sprintf("name%d", i)
if s, ok := arg.(string); ok {
arguments = append(arguments, ArgumentMarshaling{name, s, s, nil, false})
} else if components, ok := arg.([]interface{}); ok {
} else if components, ok := arg.([]any); ok {
subArgs, err := assembleArgs(components)
if err != nil {
return nil, fmt.Errorf("failed to assemble components: %v", err)
@ -154,7 +154,7 @@ func ParseSelector(unescapedSelector string) (SelectorMarshaling, error) {
if err != nil {
return SelectorMarshaling{}, fmt.Errorf("failed to parse selector '%s': %v", unescapedSelector, err)
}
args := []interface{}{}
args := []any{}
if len(rest) >= 2 && rest[0] == '(' && rest[1] == ')' {
rest = rest[2:]
} else {

View file

@ -25,7 +25,7 @@ import (
func TestParseSelector(t *testing.T) {
t.Parallel()
mkType := func(types ...interface{}) []ArgumentMarshaling {
mkType := func(types ...any) []ArgumentMarshaling {
var result []ArgumentMarshaling
for i, typeOrComponents := range types {
name := fmt.Sprintf("name%d", i)

View file

@ -29,7 +29,7 @@ import (
)
// MakeTopics converts a filter query argument list into a filter topic set.
func MakeTopics(query ...[]interface{}) ([][]common.Hash, error) {
func MakeTopics(query ...[]any) ([][]common.Hash, error) {
topics := make([][]common.Hash, len(query))
for i, filter := range query {
for _, rule := range filter {
@ -112,18 +112,18 @@ func genIntType(rule int64, size uint) []byte {
}
// ParseTopics converts the indexed topic fields into actual log field values.
func ParseTopics(out interface{}, fields Arguments, topics []common.Hash) error {
func ParseTopics(out any, fields Arguments, topics []common.Hash) error {
return parseTopicWithSetter(fields, topics,
func(arg Argument, reconstr interface{}) {
func(arg Argument, reconstr any) {
field := reflect.ValueOf(out).Elem().FieldByName(ToCamelCase(arg.Name))
field.Set(reflect.ValueOf(reconstr))
})
}
// ParseTopicsIntoMap converts the indexed topic field-value pairs into map key-value pairs.
func ParseTopicsIntoMap(out map[string]interface{}, fields Arguments, topics []common.Hash) error {
func ParseTopicsIntoMap(out map[string]any, fields Arguments, topics []common.Hash) error {
return parseTopicWithSetter(fields, topics,
func(arg Argument, reconstr interface{}) {
func(arg Argument, reconstr any) {
out[arg.Name] = reconstr
})
}
@ -133,7 +133,7 @@ func ParseTopicsIntoMap(out map[string]interface{}, fields Arguments, topics []c
//
// Note, dynamic types cannot be reconstructed since they get mapped to Keccak256
// hashes as the topic value!
func parseTopicWithSetter(fields Arguments, topics []common.Hash, setter func(Argument, interface{})) error {
func parseTopicWithSetter(fields Arguments, topics []common.Hash, setter func(Argument, any)) error {
// Sanity check that the fields and topics match up
if len(fields) != len(topics) {
return errors.New("topic/field count mismatch")
@ -143,7 +143,7 @@ func parseTopicWithSetter(fields Arguments, topics []common.Hash, setter func(Ar
if !arg.Indexed {
return errors.New("non-indexed field in topic reconstruction")
}
var reconstr interface{}
var reconstr any
switch arg.Type.T {
case TupleTy:
return errors.New("tuple type in topic reconstruction")

View file

@ -29,7 +29,7 @@ import (
func TestMakeTopics(t *testing.T) {
t.Parallel()
type args struct {
query [][]interface{}
query [][]any
}
tests := []struct {
name string
@ -39,25 +39,25 @@ func TestMakeTopics(t *testing.T) {
}{
{
"support fixed byte types, right padded to 32 bytes",
args{[][]interface{}{{[5]byte{1, 2, 3, 4, 5}}}},
args{[][]any{{[5]byte{1, 2, 3, 4, 5}}}},
[][]common.Hash{{common.Hash{1, 2, 3, 4, 5}}},
false,
},
{
"support common hash types in topics",
args{[][]interface{}{{common.Hash{1, 2, 3, 4, 5}}}},
args{[][]any{{common.Hash{1, 2, 3, 4, 5}}}},
[][]common.Hash{{common.Hash{1, 2, 3, 4, 5}}},
false,
},
{
"support address types in topics",
args{[][]interface{}{{common.Address{1, 2, 3, 4, 5}}}},
args{[][]any{{common.Address{1, 2, 3, 4, 5}}}},
[][]common.Hash{{common.Hash{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5}}},
false,
},
{
"support positive *big.Int types in topics",
args{[][]interface{}{
args{[][]any{
{big.NewInt(1)},
{big.NewInt(1).Lsh(big.NewInt(2), 254)},
}},
@ -69,7 +69,7 @@ func TestMakeTopics(t *testing.T) {
},
{
"support negative *big.Int types in topics",
args{[][]interface{}{
args{[][]any{
{big.NewInt(-1)},
{big.NewInt(math.MinInt64)},
}},
@ -81,7 +81,7 @@ func TestMakeTopics(t *testing.T) {
},
{
"support boolean types in topics",
args{[][]interface{}{
args{[][]any{
{true},
{false},
}},
@ -93,7 +93,7 @@ func TestMakeTopics(t *testing.T) {
},
{
"support int/uint(8/16/32/64) types in topics",
args{[][]interface{}{
args{[][]any{
{int8(-2)},
{int16(-3)},
{int32(-4)},
@ -125,13 +125,13 @@ func TestMakeTopics(t *testing.T) {
},
{
"support string types in topics",
args{[][]interface{}{{"hello world"}}},
args{[][]any{{"hello world"}}},
[][]common.Hash{{crypto.Keccak256Hash([]byte("hello world"))}},
false,
},
{
"support byte slice types in topics",
args{[][]interface{}{{[]byte{1, 2, 3}}}},
args{[][]any{{[]byte{1, 2, 3}}}},
[][]common.Hash{{crypto.Keccak256Hash([]byte{1, 2, 3})}},
false,
},
@ -155,7 +155,7 @@ func TestMakeTopics(t *testing.T) {
want := [][]common.Hash{{common.HexToHash("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")}}
in := big.NewInt(-1)
got, err := MakeTopics([]interface{}{in})
got, err := MakeTopics([]any{in})
if err != nil {
t.Fatalf("makeTopics() error = %v", err)
}
@ -169,9 +169,9 @@ func TestMakeTopics(t *testing.T) {
}
type args struct {
createObj func() interface{}
resultObj func() interface{}
resultMap func() map[string]interface{}
createObj func() any
resultObj func() any
resultMap func() map[string]any
fields Arguments
topics []common.Hash
}
@ -212,10 +212,10 @@ func setupTopicsTests() []topicTest {
{
name: "support fixed byte types, right padded to 32 bytes",
args: args{
createObj: func() interface{} { return &bytesStruct{} },
resultObj: func() interface{} { return &bytesStruct{StaticBytes: [5]byte{1, 2, 3, 4, 5}} },
resultMap: func() map[string]interface{} {
return map[string]interface{}{"staticBytes": [5]byte{1, 2, 3, 4, 5}}
createObj: func() any { return &bytesStruct{} },
resultObj: func() any { return &bytesStruct{StaticBytes: [5]byte{1, 2, 3, 4, 5}} },
resultMap: func() map[string]any {
return map[string]any{"staticBytes": [5]byte{1, 2, 3, 4, 5}}
},
fields: Arguments{Argument{
Name: "staticBytes",
@ -231,10 +231,10 @@ func setupTopicsTests() []topicTest {
{
name: "int8 with negative value",
args: args{
createObj: func() interface{} { return &int8Struct{} },
resultObj: func() interface{} { return &int8Struct{Int8Value: -1} },
resultMap: func() map[string]interface{} {
return map[string]interface{}{"int8Value": int8(-1)}
createObj: func() any { return &int8Struct{} },
resultObj: func() any { return &int8Struct{Int8Value: -1} },
resultMap: func() map[string]any {
return map[string]any{"int8Value": int8(-1)}
},
fields: Arguments{Argument{
Name: "int8Value",
@ -251,10 +251,10 @@ func setupTopicsTests() []topicTest {
{
name: "int256 with negative value",
args: args{
createObj: func() interface{} { return &int256Struct{} },
resultObj: func() interface{} { return &int256Struct{Int256Value: big.NewInt(-1)} },
resultMap: func() map[string]interface{} {
return map[string]interface{}{"int256Value": big.NewInt(-1)}
createObj: func() any { return &int256Struct{} },
resultObj: func() any { return &int256Struct{Int256Value: big.NewInt(-1)} },
resultMap: func() map[string]any {
return map[string]any{"int256Value": big.NewInt(-1)}
},
fields: Arguments{Argument{
Name: "int256Value",
@ -271,10 +271,10 @@ func setupTopicsTests() []topicTest {
{
name: "hash type",
args: args{
createObj: func() interface{} { return &hashStruct{} },
resultObj: func() interface{} { return &hashStruct{crypto.Keccak256Hash([]byte("stringtopic"))} },
resultMap: func() map[string]interface{} {
return map[string]interface{}{"hashValue": crypto.Keccak256Hash([]byte("stringtopic"))}
createObj: func() any { return &hashStruct{} },
resultObj: func() any { return &hashStruct{crypto.Keccak256Hash([]byte("stringtopic"))} },
resultMap: func() map[string]any {
return map[string]any{"hashValue": crypto.Keccak256Hash([]byte("stringtopic"))}
},
fields: Arguments{Argument{
Name: "hashValue",
@ -290,13 +290,13 @@ func setupTopicsTests() []topicTest {
{
name: "function type",
args: args{
createObj: func() interface{} { return &funcStruct{} },
resultObj: func() interface{} {
createObj: func() any { return &funcStruct{} },
resultObj: func() any {
return &funcStruct{[24]byte{255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}}
},
resultMap: func() map[string]interface{} {
return map[string]interface{}{"funcValue": [24]byte{255, 255, 255, 255, 255, 255, 255, 255,
resultMap: func() map[string]any {
return map[string]any{"funcValue": [24]byte{255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}}
},
fields: Arguments{Argument{
@ -314,9 +314,9 @@ func setupTopicsTests() []topicTest {
{
name: "error on topic/field count mismatch",
args: args{
createObj: func() interface{} { return nil },
resultObj: func() interface{} { return nil },
resultMap: func() map[string]interface{} { return make(map[string]interface{}) },
createObj: func() any { return nil },
resultObj: func() any { return nil },
resultMap: func() map[string]any { return make(map[string]any) },
fields: Arguments{Argument{
Name: "tupletype",
Type: tupleType,
@ -329,9 +329,9 @@ func setupTopicsTests() []topicTest {
{
name: "error on unindexed arguments",
args: args{
createObj: func() interface{} { return &int256Struct{} },
resultObj: func() interface{} { return &int256Struct{} },
resultMap: func() map[string]interface{} { return make(map[string]interface{}) },
createObj: func() any { return &int256Struct{} },
resultObj: func() any { return &int256Struct{} },
resultMap: func() map[string]any { return make(map[string]any) },
fields: Arguments{Argument{
Name: "int256Value",
Type: int256Type,
@ -347,9 +347,9 @@ func setupTopicsTests() []topicTest {
{
name: "error on tuple in topic reconstruction",
args: args{
createObj: func() interface{} { return &tupleType },
resultObj: func() interface{} { return &tupleType },
resultMap: func() map[string]interface{} { return make(map[string]interface{}) },
createObj: func() any { return &tupleType },
resultObj: func() any { return &tupleType },
resultMap: func() map[string]any { return make(map[string]any) },
fields: Arguments{Argument{
Name: "tupletype",
Type: tupleType,
@ -362,10 +362,10 @@ func setupTopicsTests() []topicTest {
{
name: "error on improper encoded function",
args: args{
createObj: func() interface{} { return &funcStruct{} },
resultObj: func() interface{} { return &funcStruct{} },
resultMap: func() map[string]interface{} {
return make(map[string]interface{})
createObj: func() any { return &funcStruct{} },
resultObj: func() any { return &funcStruct{} },
resultMap: func() map[string]any {
return make(map[string]any)
},
fields: Arguments{Argument{
Name: "funcValue",
@ -410,7 +410,7 @@ func TestParseTopicsIntoMap(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
outMap := make(map[string]interface{})
outMap := make(map[string]any)
if err := ParseTopicsIntoMap(outMap, tt.args.fields, tt.args.topics); (err != nil) != tt.wantErr {
t.Errorf("parseTopicsIntoMap() error = %v, wantErr %v", err, tt.wantErr)
}

View file

@ -122,7 +122,7 @@ func TestTypeCheck(t *testing.T) {
for i, test := range []struct {
typ string
components []ArgumentMarshaling
input interface{}
input any
err string
}{
{"uint", nil, big.NewInt(1), "unsupported arg type: uint"},

View file

@ -35,7 +35,7 @@ var (
)
// ReadInteger reads the integer based on its kind and returns the appropriate value.
func ReadInteger(typ Type, b []byte) (interface{}, error) {
func ReadInteger(typ Type, b []byte) (any, error) {
ret := new(big.Int).SetBytes(b)
if typ.T == UintTy {
@ -137,7 +137,7 @@ func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) {
}
// ReadFixedBytes uses reflection to create a fixed array to be read from.
func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
func ReadFixedBytes(t Type, word []byte) (any, error) {
if t.T != FixedBytesTy {
return nil, errors.New("abi: invalid type in call to make fixed byte array")
}
@ -149,7 +149,7 @@ func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
}
// forEachUnpack iteratively unpack elements.
func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error) {
func forEachUnpack(t Type, output []byte, start, size int) (any, error) {
if size < 0 {
return nil, fmt.Errorf("cannot marshal input to array, size is negative (%d)", size)
}
@ -189,7 +189,7 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
return refSlice.Interface(), nil
}
func forTupleUnpack(t Type, output []byte) (interface{}, error) {
func forTupleUnpack(t Type, output []byte) (any, error) {
retval := reflect.New(t.GetType()).Elem()
virtualArgs := 0
for index, elem := range t.TupleElems {
@ -221,7 +221,7 @@ func forTupleUnpack(t Type, output []byte) (interface{}, error) {
// toGoType parses the output bytes and recursively assigns the value of these bytes
// into a go type with accordance with the ABI spec.
func toGoType(index int, t Type, output []byte) (interface{}, error) {
func toGoType(index int, t Type, output []byte) (any, error) {
if index+32 > len(output) {
return nil, fmt.Errorf("abi: cannot marshal in to go type: length insufficient %d require %d", len(output), index+32)
}

View file

@ -101,7 +101,7 @@ func TestUnpack(t *testing.T) {
type unpackTest struct {
def string // ABI definition JSON
enc string // evm return data
want interface{} // the expected output
want any // the expected output
err string // empty or error if expected
}
@ -370,16 +370,16 @@ func TestMethodMultiReturn(t *testing.T) {
Int *big.Int
}
newInterfaceSlice := func(len int) interface{} {
slice := make([]interface{}, len)
newInterfaceSlice := func(len int) any {
slice := make([]any, len)
return &slice
}
abi, data, expected := methodMultiReturn(require.New(t))
bigint := new(big.Int)
var testCases = []struct {
dest interface{}
expected interface{}
dest any
expected any
error string
name string
}{{
@ -393,38 +393,38 @@ func TestMethodMultiReturn(t *testing.T) {
"",
"Can unpack into reversed structure",
}, {
&[]interface{}{&bigint, new(string)},
&[]interface{}{&expected.Int, &expected.String},
&[]any{&bigint, new(string)},
&[]any{&expected.Int, &expected.String},
"",
"Can unpack into a slice",
}, {
&[]interface{}{&bigint, ""},
&[]interface{}{&expected.Int, expected.String},
&[]any{&bigint, ""},
&[]any{&expected.Int, expected.String},
"",
"Can unpack into a slice without indirection",
}, {
&[2]interface{}{&bigint, new(string)},
&[2]interface{}{&expected.Int, &expected.String},
&[2]any{&bigint, new(string)},
&[2]any{&expected.Int, &expected.String},
"",
"Can unpack into an array",
}, {
&[2]interface{}{},
&[2]interface{}{expected.Int, expected.String},
&[2]any{},
&[2]any{expected.Int, expected.String},
"",
"Can unpack into interface array",
}, {
newInterfaceSlice(2),
&[]interface{}{expected.Int, expected.String},
&[]any{expected.Int, expected.String},
"",
"Can unpack into interface slice",
}, {
&[]interface{}{new(int), new(int)},
&[]interface{}{&expected.Int, &expected.String},
&[]any{new(int), new(int)},
&[]any{&expected.Int, &expected.String},
"abi: cannot unmarshal *big.Int in to int",
"Can not unpack into a slice with wrong types",
}, {
&[]interface{}{new(int)},
&[]interface{}{},
&[]any{new(int)},
&[]any{},
"abi: insufficient number of arguments for unpack, want 2, got 1",
"Can not unpack into a slice with wrong types",
}}
@ -455,7 +455,7 @@ func TestMultiReturnWithArray(t *testing.T) {
ret1, ret1Exp := new([3]uint64), [3]uint64{9, 9, 9}
ret2, ret2Exp := new(uint64), uint64(8)
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
if err := abi.UnpackIntoInterface(&[]any{ret1, ret2}, "multi", buff.Bytes()); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(*ret1, ret1Exp) {
@ -480,7 +480,7 @@ func TestMultiReturnWithStringArray(t *testing.T) {
ret2, ret2Exp := new(common.Address), common.HexToAddress("ab1257528b3782fb40d7ed5f72e624b744dffb2f")
ret3, ret3Exp := new([2]string), [2]string{"Ethereum", "Hello, Ethereum!"}
ret4, ret4Exp := new(bool), false
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2, ret3, ret4}, "multi", buff.Bytes()); err != nil {
if err := abi.UnpackIntoInterface(&[]any{ret1, ret2, ret3, ret4}, "multi", buff.Bytes()); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(*ret1, ret1Exp) {
@ -519,7 +519,7 @@ func TestMultiReturnWithStringSlice(t *testing.T) {
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000065")) // output[1][1] value
ret1, ret1Exp := new([]string), []string{"ethereum", "go-ethereum"}
ret2, ret2Exp := new([]*big.Int), []*big.Int{big.NewInt(100), big.NewInt(101)}
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
if err := abi.UnpackIntoInterface(&[]any{ret1, ret2}, "multi", buff.Bytes()); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(*ret1, ret1Exp) {
@ -560,7 +560,7 @@ func TestMultiReturnWithDeeplyNestedArray(t *testing.T) {
{{0x411, 0x412, 0x413}, {0x421, 0x422, 0x423}},
}
ret2, ret2Exp := new(uint64), uint64(0x9876)
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
if err := abi.UnpackIntoInterface(&[]any{ret1, ret2}, "multi", buff.Bytes()); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(*ret1, ret1Exp) {
@ -593,7 +593,7 @@ func TestUnmarshal(t *testing.T) {
// marshall mixed bytes (mixedBytes)
p0, p0Exp := []byte{}, common.Hex2Bytes("01020000000000000000")
p1, p1Exp := [32]byte{}, common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000ddeeff")
mixedBytes := []interface{}{&p0, &p1}
mixedBytes := []any{&p0, &p1}
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000040"))
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000ddeeff"))
@ -1016,7 +1016,7 @@ func TestPackAndUnpackIncompatibleNumber(t *testing.T) {
inputValue *big.Int
unpackErr error
packErr error
expectValue interface{}
expectValue any
}{
{
decodeType: "uint8",

View file

@ -82,7 +82,7 @@ type CryptoJSON struct {
CipherText string `json:"ciphertext"`
CipherParams cipherparamsJSON `json:"cipherparams"`
KDF string `json:"kdf"`
KDFParams map[string]interface{} `json:"kdfparams"`
KDFParams map[string]any `json:"kdfparams"`
MAC string `json:"mac"`
}

View file

@ -158,7 +158,7 @@ func EncryptDataV3(data, auth []byte, scryptN, scryptP int) (CryptoJSON, error)
}
mac := crypto.Keccak256(derivedKey[16:32], cipherText)
scryptParamsJSON := make(map[string]interface{}, 5)
scryptParamsJSON := make(map[string]any, 5)
scryptParamsJSON["n"] = scryptN
scryptParamsJSON["r"] = scryptR
scryptParamsJSON["p"] = scryptP
@ -199,7 +199,7 @@ func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error) {
// DecryptKey decrypts a key from a json blob, returning the private key itself.
func DecryptKey(keyjson []byte, auth string) (*Key, error) {
// Parse the json into a simple map to fetch the key version
m := make(map[string]interface{})
m := make(map[string]any)
if err := json.Unmarshal(keyjson, &m); err != nil {
return nil, err
}
@ -359,7 +359,7 @@ func getKDFKey(cryptoJSON CryptoJSON, auth string) ([]byte, error) {
// TODO: can we do without this when unmarshalling dynamic JSON?
// why do integers in KDF params end up as float64 and not int after
// unmarshal?
func ensureInt(x interface{}) int {
func ensureInt(x any) int {
res, ok := x.(int)
if !ok {
res = int(x.(float64))

View file

@ -334,24 +334,24 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
err error
)
if chainID == nil {
if txrlp, err = rlp.EncodeToBytes([]interface{}{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data()}); err != nil {
if txrlp, err = rlp.EncodeToBytes([]any{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data()}); err != nil {
return common.Address{}, nil, err
}
} else {
if tx.Type() == types.DynamicFeeTxType {
if txrlp, err = rlp.EncodeToBytes([]interface{}{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
return common.Address{}, nil, err
}
// append type to transaction
txrlp = append([]byte{tx.Type()}, txrlp...)
} else if tx.Type() == types.AccessListTxType {
if txrlp, err = rlp.EncodeToBytes([]interface{}{chainID, tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
return common.Address{}, nil, err
}
// append type to transaction
txrlp = append([]byte{tx.Type()}, txrlp...)
} else if tx.Type() == types.LegacyTxType {
if txrlp, err = rlp.EncodeToBytes([]interface{}{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), chainID, big.NewInt(0), big.NewInt(0)}); err != nil {
if txrlp, err = rlp.EncodeToBytes([]any{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), chainID, big.NewInt(0), big.NewInt(0)}); err != nil {
return common.Address{}, nil, err
}
}

View file

@ -31,7 +31,7 @@ type EngineAPIError struct {
func (e *EngineAPIError) ErrorCode() int { return e.code }
func (e *EngineAPIError) Error() string { return e.msg }
func (e *EngineAPIError) ErrorData() interface{} {
func (e *EngineAPIError) ErrorData() any {
if e.err == nil {
return nil
}

View file

@ -104,7 +104,7 @@ func makeTestHeaderWithMerkleProof(slot, index uint64, value merkle.Value) (type
}
// syncCommittee holds either a blsSyncCommittee or a fake dummySyncCommittee used for testing
type syncCommittee interface{}
type syncCommittee any
// committeeSigVerifier verifies sync committee signatures (either proper BLS
// signatures or fake signatures used for testing)

View file

@ -1227,7 +1227,7 @@ func doWindowsInstaller(cmdline []string) {
// Render NSIS scripts: Installer NSIS contains two installer sections,
// first section contains the geth binary, second section holds the dev tools.
templateData := map[string]interface{}{
templateData := map[string]any{
"License": "COPYING",
"Geth": gethTool,
"DevTools": devTools,

View file

@ -68,7 +68,7 @@ func main() {
}
}
func die(args ...interface{}) {
func die(args ...any) {
fmt.Fprintln(os.Stderr, args...)
os.Exit(1)
}

View file

@ -779,7 +779,7 @@ func signer(c *cli.Context) error {
go testExternalUI(apiImpl)
}
ui.OnSignerStartup(core.StartupInfo{
Info: map[string]interface{}{
Info: map[string]any{
"intapi_version": core.InternalAPIVersion,
"extapi_version": core.ExternalAPIVersion,
"extapi_http": extapiURL,
@ -1084,7 +1084,7 @@ func GenDoc(ctx *cli.Context) error {
UserAgent: "Firefox 3.2",
}
output []string
add = func(name, desc string, v interface{}) {
add = func(name, desc string, v any) {
if data, err := json.MarshalIndent(v, "", " "); err == nil {
output = append(output, fmt.Sprintf("### %s\n\n%s\n\nExample:\n```json\n%s\n```", name, desc, data))
} else {

View file

@ -98,7 +98,7 @@ func dumpNodeURL(out io.Writer, n *enode.Node) {
fmt.Fprintf(out, "URLv4: %s\n", n.URLv4())
}
func dumpRecordKV(kv []interface{}, indent int) string {
func dumpRecordKV(kv []any, indent int) string {
// Determine the longest key name for alignment.
var out string
var longestKey = 0

View file

@ -44,10 +44,10 @@ func (p *readError) Unwrap() error { return p.err }
func (p *readError) RequestID() []byte { return nil }
func (p *readError) SetRequestID([]byte) {}
func (p *readError) AppendLogInfo(ctx []interface{}) []interface{} { return ctx }
func (p *readError) AppendLogInfo(ctx []any) []any { return ctx }
// readErrorf creates a readError with the given text.
func readErrorf(format string, args ...interface{}) *readError {
func readErrorf(format string, args ...any) *readError {
return &readError{fmt.Errorf(format, args...)}
}
@ -68,7 +68,7 @@ type conn struct {
}
type logger interface {
Logf(string, ...interface{})
Logf(string, ...any)
}
// newConn sets up a connection to the given node.
@ -231,7 +231,7 @@ func (tc *conn) read(c net.PacketConn) v5wire.Packet {
}
// logf prints to the test log.
func (tc *conn) logf(format string, args ...interface{}) {
func (tc *conn) logf(format string, args ...any) {
if tc.log != nil {
tc.log.Logf("(%s) %s", tc.localNode.ID().TerminalString(), fmt.Sprintf(format, args...))
}

View file

@ -92,7 +92,7 @@ func getNodeArg(ctx *cli.Context) *enode.Node {
return n
}
func exit(err interface{}) {
func exit(err any) {
if err == nil {
os.Exit(0)
}

View file

@ -72,7 +72,7 @@ func nodesetInfo(ctx *cli.Context) error {
// showAttributeCounts prints the distribution of ENR attributes in a node set.
func showAttributeCounts(ns nodeSet) {
attrcount := make(map[string]int)
var attrlist []interface{}
var attrlist []any
for _, n := range ns {
r := n.N.Record()
attrlist = r.AppendElements(attrlist[:0])[1:]

View file

@ -47,7 +47,7 @@ func getPassphrase(ctx *cli.Context, confirmation bool) string {
// mustPrintJSON prints the JSON encoding of the given object and
// exits the program with an error message when the marshaling fails.
func mustPrintJSON(jsonObject interface{}) {
func mustPrintJSON(jsonObject any) {
str, err := json.MarshalIndent(jsonObject, "", " ")
if err != nil {
utils.Fatalf("Failed to marshal JSON object: %v", err)

View file

@ -318,7 +318,7 @@ func (g Alloc) OnAccount(addr *common.Address, dumpAccount state.DumpAccount) {
}
// saveFile marshals the object to the given file
func saveFile(baseDir, filename string, data interface{}) error {
func saveFile(baseDir, filename string, data any) error {
b, err := json.MarshalIndent(data, "", " ")
if err != nil {
return NewError(ErrorJson, fmt.Errorf("failed marshalling output: %v", err))
@ -334,9 +334,9 @@ func saveFile(baseDir, filename string, data interface{}) error {
// dispatchOutput writes the output data to either stderr or stdout, or to the specified
// files
func dispatchOutput(ctx *cli.Context, baseDir string, result *ExecutionResult, alloc Alloc, body hexutil.Bytes, bt map[common.Hash]hexutil.Bytes) error {
stdOutObject := make(map[string]interface{})
stdErrObject := make(map[string]interface{})
dispatch := func(baseDir, fName, name string, obj interface{}) error {
stdOutObject := make(map[string]any)
stdErrObject := make(map[string]any)
dispatch := func(baseDir, fName, name string, obj any) error {
switch fName {
case "stdout":
stdOutObject[name] = obj

View file

@ -25,7 +25,7 @@ import (
)
// readFile reads the json-data in the provided path and marshals into dest.
func readFile(path, desc string, dest interface{}) error {
func readFile(path, desc string, dest any) error {
inFile, err := os.Open(path)
if err != nil {
return NewError(ErrorIO, fmt.Errorf("failed reading %s file: %v", desc, err))

View file

@ -736,7 +736,7 @@ func TestEvmRunRegEx(t *testing.T) {
// cmpJson compares the JSON in two byte slices.
func cmpJson(a, b []byte) (bool, error) {
var j, j2 interface{}
var j, j2 any
if err := json.Unmarshal(a, &j); err != nil {
return false, err
}

View file

@ -174,7 +174,7 @@ func ws(n int) string {
return strings.Repeat(" ", n)
}
func die(args ...interface{}) {
func die(args ...any) {
fmt.Fprintln(os.Stderr, args...)
os.Exit(1)
}
@ -187,7 +187,7 @@ func textToRlp(r io.Reader) ([]byte, error) {
// - an element is either hex-encoded bytes OR a quoted string
var (
scanner = bufio.NewScanner(r)
obj []interface{}
obj []any
stack = list.New()
)
for scanner.Scan() {
@ -198,12 +198,12 @@ func textToRlp(r io.Reader) ([]byte, error) {
switch t {
case "[": // list start
stack.PushFront(obj)
obj = make([]interface{}, 0)
obj = make([]any, 0)
case "]", "],": // list end
parent := stack.Remove(stack.Front()).([]interface{})
parent := stack.Remove(stack.Front()).([]any)
obj = append(parent, obj)
case "[],": // empty list
obj = append(obj, make([]interface{}, 0))
obj = append(obj, make([]any, 0))
default: // element
data := []byte(t)[:len(t)-1] // cut off comma
if data[0] == '"' { // ascii string

View file

@ -63,7 +63,7 @@ var ErrImportInterrupted = errors.New("interrupted")
// Fatalf formats a message to standard error and exits the program.
// The message is also printed to standard output if standard error
// is redirected to a different file.
func Fatalf(format string, args ...interface{}) {
func Fatalf(format string, args ...any) {
w := io.MultiWriter(os.Stdout, os.Stderr)
if runtime.GOOS == "windows" || runtime.GOOS == "openbsd" {
// The SameFile check below doesn't work on Windows neither OpenBSD.

View file

@ -36,10 +36,10 @@ type ContractInfo struct {
LanguageVersion string `json:"languageVersion"`
CompilerVersion string `json:"compilerVersion"`
CompilerOptions string `json:"compilerOptions"`
SrcMap interface{} `json:"srcMap"`
SrcMap any `json:"srcMap"`
SrcMapRuntime string `json:"srcMapRuntime"`
AbiDefinition interface{} `json:"abiDefinition"`
UserDoc interface{} `json:"userDoc"`
DeveloperDoc interface{} `json:"developerDoc"`
AbiDefinition any `json:"abiDefinition"`
UserDoc any `json:"userDoc"`
DeveloperDoc any `json:"developerDoc"`
Metadata string `json:"metadata"`
}

View file

@ -39,9 +39,9 @@ type solcOutputV8 struct {
BinRuntime string `json:"bin-runtime"`
SrcMapRuntime string `json:"srcmap-runtime"`
Bin, SrcMap, Metadata string
Abi interface{}
Devdoc interface{}
Userdoc interface{}
Abi any
Devdoc any
Userdoc any
Hashes map[string]string
}
Version string
@ -66,7 +66,7 @@ func ParseCombinedJSON(combinedJSON []byte, source string, languageVersion strin
contracts := make(map[string]*Contract)
for name, info := range output.Contracts {
// Parse the individual compilation results.
var abi, userdoc, devdoc interface{}
var abi, userdoc, devdoc any
if err := json.Unmarshal([]byte(info.Abi), &abi); err != nil {
return nil, fmt.Errorf("solc: error reading abi definition (%v)", err)
}

View file

@ -25,7 +25,7 @@ import (
)
// Report gives off a warning requesting the user to submit an issue to the github tracker.
func Report(extra ...interface{}) {
func Report(extra ...any) {
fmt.Fprintln(os.Stderr, "You've encountered a sought after, hard to reproduce bug. Please report this to the developers <3 https://github.com/ethereum/go-ethereum/issues")
fmt.Fprintln(os.Stderr, extra...)

View file

@ -23,13 +23,13 @@ import (
)
type marshalTest struct {
input interface{}
input any
want string
}
type unmarshalTest struct {
input string
want interface{}
want any
wantErr error // if set, decoding must fail on any platform
wantErr32bit error // if set, decoding must fail on 32bit platforms (used for Uint tests)
}

View file

@ -79,7 +79,7 @@ func (b Bytes) String() string {
func (b Bytes) ImplementsGraphQLType(name string) bool { return name == "Bytes" }
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (b *Bytes) UnmarshalGraphQL(input interface{}) error {
func (b *Bytes) UnmarshalGraphQL(input any) error {
var err error
switch input := input.(type) {
case string:
@ -213,7 +213,7 @@ func (b *Big) String() string {
func (b Big) ImplementsGraphQLType(name string) bool { return name == "BigInt" }
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (b *Big) UnmarshalGraphQL(input interface{}) error {
func (b *Big) UnmarshalGraphQL(input any) error {
var err error
switch input := input.(type) {
case string:
@ -321,7 +321,7 @@ func (b Uint64) String() string {
func (b Uint64) ImplementsGraphQLType(name string) bool { return name == "Long" }
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (b *Uint64) UnmarshalGraphQL(input interface{}) error {
func (b *Uint64) UnmarshalGraphQL(input any) error {
var err error
switch input := input.(type) {
case string:

View file

@ -193,13 +193,13 @@ func (h *simTimerHeap) Swap(i, j int) {
(*h)[j].index = j
}
func (h *simTimerHeap) Push(x interface{}) {
func (h *simTimerHeap) Push(x any) {
t := x.(*simTimer)
t.index = len(*h)
*h = append(*h, t)
}
func (h *simTimerHeap) Pop() interface{} {
func (h *simTimerHeap) Pop() any {
end := len(*h) - 1
t := (*h)[end]
t.index = -1

View file

@ -40,18 +40,18 @@ type lazyItem struct {
index int
}
func testPriority(a interface{}) int64 {
func testPriority(a any) int64 {
return a.(*lazyItem).p
}
func testMaxPriority(a interface{}, until mclock.AbsTime) int64 {
func testMaxPriority(a any, until mclock.AbsTime) int64 {
i := a.(*lazyItem)
dt := until - i.last
i.maxp = i.p + int64(float64(dt)*testAvgRate)
return i.maxp
}
func testSetIndex(a interface{}, i int) {
func testSetIndex(a any, i int) {
a.(*lazyItem).index = i
}

View file

@ -23,7 +23,7 @@ import (
)
// LoadJSON reads the given file and unmarshals its content.
func LoadJSON(file string, val interface{}) error {
func LoadJSON(file string, val any) error {
content, err := os.ReadFile(file)
if err != nil {
return err

View file

@ -171,7 +171,7 @@ func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value {
}
// Scan implements Scanner for database/sql.
func (h *Hash) Scan(src interface{}) error {
func (h *Hash) Scan(src any) error {
srcB, ok := src.([]byte)
if !ok {
return fmt.Errorf("can't scan %T into Hash", src)
@ -192,7 +192,7 @@ func (h Hash) Value() (driver.Value, error) {
func (Hash) ImplementsGraphQLType(name string) bool { return name == "Bytes32" }
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (h *Hash) UnmarshalGraphQL(input interface{}) error {
func (h *Hash) UnmarshalGraphQL(input any) error {
var err error
switch input := input.(type) {
case string:
@ -348,7 +348,7 @@ func (a *Address) UnmarshalJSON(input []byte) error {
}
// Scan implements Scanner for database/sql.
func (a *Address) Scan(src interface{}) error {
func (a *Address) Scan(src any) error {
srcB, ok := src.([]byte)
if !ok {
return fmt.Errorf("can't scan %T into Address", src)
@ -369,7 +369,7 @@ func (a Address) Value() (driver.Value, error) {
func (a Address) ImplementsGraphQLType(name string) bool { return name == "Address" }
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (a *Address) UnmarshalGraphQL(input interface{}) error {
func (a *Address) UnmarshalGraphQL(input any) error {
var err error
switch input := input.(type) {
case string:

View file

@ -223,7 +223,7 @@ func TestMixedcaseAccount_Address(t *testing.T) {
func TestHash_Scan(t *testing.T) {
type args struct {
src interface{}
src any
}
tests := []struct {
name string
@ -314,7 +314,7 @@ func TestHash_Value(t *testing.T) {
func TestAddress_Scan(t *testing.T) {
type args struct {
src interface{}
src any
}
tests := []struct {
name string

View file

@ -662,7 +662,7 @@ func CliqueRLP(header *types.Header) []byte {
}
func encodeSigHeader(w io.Writer, header *types.Header) {
enc := []interface{}{
enc := []any{
header.ParentHash,
header.UncleHash,
header.Coinbase,

View file

@ -529,7 +529,7 @@ func (ethash *Ethash) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
hasher := sha3.NewLegacyKeccak256()
enc := []interface{}{
enc := []any{
header.ParentHash,
header.UncleHash,
header.Coinbase,

View file

@ -113,7 +113,7 @@ func (b *bridge) SleepBlocks(call jsre.Call) (goja.Value, error) {
type jsonrpcCall struct {
ID int64
Method string
Params []interface{}
Params []any
}
// Send implements the web3 provider "send" method.
@ -168,7 +168,7 @@ func (b *bridge) Send(call jsre.Call) (goja.Value, error) {
}
} else {
code := -32603
var data interface{}
var data any
if err, ok := err.(rpc.Error); ok {
code = err.ErrorCode()
}
@ -194,8 +194,8 @@ func (b *bridge) Send(call jsre.Call) (goja.Value, error) {
return result, nil
}
func setError(resp *goja.Object, code int, msg string, data interface{}) {
err := make(map[string]interface{})
func setError(resp *goja.Object, code int, msg string, data any) {
err := make(map[string]any)
err["code"] = code
err["message"] = msg
if data != nil {

View file

@ -1578,14 +1578,14 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
}
var (
head = blockChain[len(blockChain)-1]
context = []interface{}{
context = []any{
"count", stats.processed, "elapsed", common.PrettyDuration(time.Since(start)),
"number", head.Number(), "hash", head.Hash(), "age", common.PrettyAge(time.Unix(int64(head.Time()), 0)),
"size", common.StorageSize(size),
}
)
if stats.ignored > 0 {
context = append(context, []interface{}{"ignored", stats.ignored}...)
context = append(context, []any{"ignored", stats.ignored}...)
}
log.Debug("Imported new block receipts", context...)
return 0, nil
@ -2693,14 +2693,14 @@ func (bc *BlockChain) SetCanonical(head *types.Block) (common.Hash, error) {
}
bc.chainHeadFeed.Send(ChainHeadEvent{Header: head.Header()})
context := []interface{}{
context := []any{
"number", head.Number(),
"hash", head.Hash(),
"root", head.Root(),
"elapsed", time.Since(start),
}
if timestamp := time.Unix(int64(head.Time()), 0); time.Since(timestamp) > time.Minute {
context = append(context, []interface{}{"age", common.PrettyAge(timestamp)}...)
context = append(context, []any{"age", common.PrettyAge(timestamp)}...)
}
log.Info("Chain head was updated", context...)
return head.Hash(), nil

View file

@ -56,27 +56,27 @@ func (st *insertStats) report(chain []*types.Block, index int, snapDiffItems, sn
end := chain[index]
// Assemble the log context and send it to the logger
context := []interface{}{
context := []any{
"number", end.Number(), "hash", end.Hash(),
"blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000,
"elapsed", common.PrettyDuration(elapsed), "mgasps", mgasps,
}
if timestamp := time.Unix(int64(end.Time()), 0); time.Since(timestamp) > time.Minute {
context = append(context, []interface{}{"age", common.PrettyAge(timestamp)}...)
context = append(context, []any{"age", common.PrettyAge(timestamp)}...)
}
if snapDiffItems != 0 || snapBufItems != 0 { // snapshots enabled
context = append(context, []interface{}{"snapdiffs", snapDiffItems}...)
context = append(context, []any{"snapdiffs", snapDiffItems}...)
if snapBufItems != 0 { // future snapshot refactor
context = append(context, []interface{}{"snapdirty", snapBufItems}...)
context = append(context, []any{"snapdirty", snapBufItems}...)
}
}
if trieDiffNodes != 0 { // pathdb
context = append(context, []interface{}{"triediffs", trieDiffNodes}...)
context = append(context, []any{"triediffs", trieDiffNodes}...)
}
context = append(context, []interface{}{"triedirty", triebufNodes}...)
context = append(context, []any{"triedirty", triebufNodes}...)
if st.ignored > 0 {
context = append(context, []interface{}{"ignored", st.ignored}...)
context = append(context, []any{"ignored", st.ignored}...)
}
if setHead {
log.Info("Imported new chain segment", context...)

View file

@ -327,18 +327,18 @@ func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, start time.Time)
return 0, err
}
// Report some public statistics so the user has a clue what's going on
context := []interface{}{
context := []any{
"count", res.imported,
"elapsed", common.PrettyDuration(time.Since(start)),
}
if last := res.lastHeader; last != nil {
context = append(context, "number", last.Number, "hash", res.lastHash)
if timestamp := time.Unix(int64(last.Time), 0); time.Since(timestamp) > time.Minute {
context = append(context, []interface{}{"age", common.PrettyAge(timestamp)}...)
context = append(context, []any{"age", common.PrettyAge(timestamp)}...)
}
}
if res.ignored > 0 {
context = append(context, []interface{}{"ignored", res.ignored}...)
context = append(context, []any{"ignored", res.ignored}...)
}
log.Debug("Imported new block headers", context...)
return res.status, err

View file

@ -287,11 +287,11 @@ func (f *chainFreezer) freeze(db ethdb.KeyValueStore) {
}
// Log something friendly for the user
context := []interface{}{
context := []any{
"blocks", frozen - first, "elapsed", common.PrettyDuration(time.Since(start)), "number", frozen - 1,
}
if n := len(ancients); n > 0 {
context = append(context, []interface{}{"hash", ancients[n-1]}...)
context = append(context, []any{"hash", ancients[n-1]}...)
}
log.Debug("Deep froze chain segment", context...)

View file

@ -50,7 +50,7 @@ func newFreezerBatch(f *Freezer) *freezerBatch {
}
// Append adds an RLP-encoded item of the given kind.
func (batch *freezerBatch) Append(kind string, num uint64, item interface{}) error {
func (batch *freezerBatch) Append(kind string, num uint64, item any) error {
if table := batch.tables[kind]; table != nil {
return table.Append(num, item)
}
@ -127,7 +127,7 @@ func (batch *freezerTableBatch) reset() {
// Append rlp-encodes and adds data at the end of the freezer table. The item number is a
// precautionary parameter to ensure data correctness, but the table will reject already
// existing data.
func (batch *freezerTableBatch) Append(item uint64, data interface{}) error {
func (batch *freezerTableBatch) Append(item uint64, data any) error {
if item != batch.curItem {
return fmt.Errorf("%w: have %d want %d", errOutOrderInsertion, item, batch.curItem)
}

View file

@ -167,7 +167,7 @@ func (b *memoryBatch) reset(freezer *MemoryFreezer) {
}
// Append adds an RLP-encoded item.
func (b *memoryBatch) Append(kind string, number uint64, item interface{}) error {
func (b *memoryBatch) Append(kind string, number uint64, item any) error {
if b.next[kind] != number {
return errOutOrderInsertion
}

View file

@ -49,22 +49,22 @@ type generatorStats struct {
// Log creates a contextual log with the given message and the context pulled
// from the internally maintained statistics.
func (gs *generatorStats) Log(msg string, root common.Hash, marker []byte) {
var ctx []interface{}
var ctx []any
if root != (common.Hash{}) {
ctx = append(ctx, []interface{}{"root", root}...)
ctx = append(ctx, []any{"root", root}...)
}
// Figure out whether we're after or within an account
switch len(marker) {
case common.HashLength:
ctx = append(ctx, []interface{}{"at", common.BytesToHash(marker)}...)
ctx = append(ctx, []any{"at", common.BytesToHash(marker)}...)
case 2 * common.HashLength:
ctx = append(ctx, []interface{}{
ctx = append(ctx, []any{
"in", common.BytesToHash(marker[:common.HashLength]),
"at", common.BytesToHash(marker[common.HashLength:]),
}...)
}
// Add the usual measurements
ctx = append(ctx, []interface{}{
ctx = append(ctx, []any{
"accounts", gs.accounts,
"slots", gs.slots,
"storage", gs.storage,
@ -77,7 +77,7 @@ func (gs *generatorStats) Log(msg string, root common.Hash, marker []byte) {
left := math.MaxUint64 - binary.BigEndian.Uint64(marker[:8])
speed := done/uint64(time.Since(gs.start)/time.Millisecond+1) + 1 // +1s to avoid division by zero
ctx = append(ctx, []interface{}{
ctx = append(ctx, []any{
"eta", common.PrettyDuration(time.Duration(left/speed) * time.Millisecond),
}...)
}

View file

@ -162,7 +162,7 @@ func (stat *generateStats) report() {
stat.lock.RLock()
defer stat.lock.RUnlock()
ctx := []interface{}{
ctx := []any{
"accounts", stat.accounts,
"slots", stat.slots,
"elapsed", common.PrettyDuration(time.Since(stat.start)),
@ -185,7 +185,7 @@ func (stat *generateStats) report() {
}
}
}
ctx = append(ctx, []interface{}{
ctx = append(ctx, []any{
"eta", common.PrettyDuration(eta),
}...)
}
@ -198,12 +198,12 @@ func (stat *generateStats) reportDone() {
stat.lock.RLock()
defer stat.lock.RUnlock()
var ctx []interface{}
ctx = append(ctx, []interface{}{"accounts", stat.accounts}...)
var ctx []any
ctx = append(ctx, []any{"accounts", stat.accounts}...)
if stat.slots != 0 {
ctx = append(ctx, []interface{}{"slots", stat.slots}...)
ctx = append(ctx, []any{"slots", stat.slots}...)
}
ctx = append(ctx, []interface{}{"elapsed", common.PrettyDuration(time.Since(stat.start))}...)
ctx = append(ctx, []any{"elapsed", common.PrettyDuration(time.Since(stat.start))}...)
log.Info("Iterated snapshot", ctx...)
}

View file

@ -313,7 +313,7 @@ func (dl *diskLayer) generateRange(ctx *generatorContext, trieId *trie.ID, prefi
last := result.last()
// Construct contextual logger
logCtx := []interface{}{"kind", kind, "prefix", hexutil.Encode(prefix)}
logCtx := []any{"kind", kind, "prefix", hexutil.Encode(prefix)}
if len(origin) > 0 {
logCtx = append(logCtx, "origin", hexutil.Encode(origin))
}

View file

@ -590,7 +590,7 @@ func forEachStorage(s *StateDB, addr common.Address, cb func(key, value common.H
func (test *snapshotTest) checkEqual(state, checkstate *StateDB) error {
for _, addr := range test.addrs {
var err error
checkeq := func(op string, a, b interface{}) bool {
checkeq := func(op string, a, b any) bool {
if err == nil && !reflect.DeepEqual(a, b) {
err = fmt.Errorf("got %s(%s) == %v, want %v", op, addr.Hex(), a, b)
return false

View file

@ -39,11 +39,11 @@ func (h nonceHeap) Len() int { return len(h) }
func (h nonceHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h nonceHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
func (h *nonceHeap) Push(x interface{}) {
func (h *nonceHeap) Push(x any) {
*h = append(*h, x.(uint64))
}
func (h *nonceHeap) Pop() interface{} {
func (h *nonceHeap) Pop() any {
old := *h
n := len(old)
x := old[n-1]
@ -515,12 +515,12 @@ func (h *priceHeap) cmp(a, b *types.Transaction) int {
return a.GasTipCapCmp(b)
}
func (h *priceHeap) Push(x interface{}) {
func (h *priceHeap) Push(x any) {
tx := x.(*types.Transaction)
h.list = append(h.list, tx)
}
func (h *priceHeap) Pop() interface{} {
func (h *priceHeap) Pop() any {
old := h.list
n := len(old)
x := old[n-1]

View file

@ -208,7 +208,7 @@ type Block struct {
// These fields are used by package eth to track
// inter-peer block relay.
ReceivedAt time.Time
ReceivedFrom interface{}
ReceivedFrom any
}
// "external" block encoding. used for eth protocol, etc.

View file

@ -41,7 +41,7 @@ func TestBlockEncoding(t *testing.T) {
t.Fatal("decode error: ", err)
}
check := func(f string, got, want interface{}) {
check := func(f string, got, want any) {
if !reflect.DeepEqual(got, want) {
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
}
@ -77,7 +77,7 @@ func TestEIP1559BlockEncoding(t *testing.T) {
t.Fatal("decode error: ", err)
}
check := func(f string, got, want interface{}) {
check := func(f string, got, want any) {
if !reflect.DeepEqual(got, want) {
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
}
@ -142,7 +142,7 @@ func TestEIP2718BlockEncoding(t *testing.T) {
t.Fatal("decode error: ", err)
}
check := func(f string, got, want interface{}) {
check := func(f string, got, want any) {
if !reflect.DeepEqual(got, want) {
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
}
@ -204,7 +204,7 @@ func TestEIP4844BlockEncoding(t *testing.T) {
t.Fatal("decode error: ", err)
}
check := func(f string, got, want interface{}) {
check := func(f string, got, want any) {
if !reflect.DeepEqual(got, want) {
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
}

View file

@ -29,12 +29,12 @@ import (
// hasherPool holds LegacyKeccak256 buffer for rlpHash.
var hasherPool = sync.Pool{
New: func() interface{} { return crypto.NewKeccakState() },
New: func() any { return crypto.NewKeccakState() },
}
// encodeBufferPool holds temporary encoder buffers for DeriveSha and TX encoding.
var encodeBufferPool = sync.Pool{
New: func() interface{} { return new(bytes.Buffer) },
New: func() any { return new(bytes.Buffer) },
}
// getPooledBuffer retrieves a buffer from the pool and creates a byte slice of the
@ -54,7 +54,7 @@ func getPooledBuffer(size uint64) ([]byte, *bytes.Buffer, error) {
}
// rlpHash encodes x and hashes the encoded bytes.
func rlpHash(x interface{}) (h common.Hash) {
func rlpHash(x any) (h common.Hash) {
sha := hasherPool.Get().(crypto.KeccakState)
defer hasherPool.Put(sha)
sha.Reset()
@ -65,7 +65,7 @@ func rlpHash(x interface{}) (h common.Hash) {
// prefixedRlpHash writes the prefix into the hasher before rlp-encoding x.
// It's used for typed transactions.
func prefixedRlpHash(prefix byte, x interface{}) (h common.Hash) {
func prefixedRlpHash(prefix byte, x any) (h common.Hash) {
sha := hasherPool.Get().(crypto.KeccakState)
defer hasherPool.Put(sha)
sha.Reset()

View file

@ -26,7 +26,7 @@ import (
"github.com/holiman/uint256"
)
func decodeEncode(input []byte, val interface{}) error {
func decodeEncode(input []byte, val any) error {
if err := rlp.DecodeBytes(input, val); err != nil {
// not valid rlp, nothing to do
return nil
@ -54,8 +54,8 @@ func fuzzRlp(t *testing.T, input []byte) {
if elems, _, err := rlp.SplitList(input); err == nil {
rlp.CountValues(elems)
}
rlp.NewStream(bytes.NewReader(input), 0).Decode(new(interface{}))
if err := decodeEncode(input, new(interface{})); err != nil {
rlp.NewStream(bytes.NewReader(input), 0).Decode(new(any))
if err := decodeEncode(input, new(any)); err != nil {
t.Fatal(err)
}
{
@ -73,7 +73,7 @@ func fuzzRlp(t *testing.T, input []byte) {
Bool bool
Raw rlp.RawValue
Slice []*Types
Iface []interface{}
Iface []any
}
var v Types
if err := decodeEncode(input, &v); err != nil {
@ -89,7 +89,7 @@ func fuzzRlp(t *testing.T, input []byte) {
Raw rlp.RawValue
Slice []*AllTypes
Array [3]*AllTypes
Iface []interface{}
Iface []any
}
var v AllTypes
if err := decodeEncode(input, &v); err != nil {

View file

@ -491,7 +491,7 @@ func TestTransactionSizes(t *testing.T) {
}
func TestYParityJSONUnmarshalling(t *testing.T) {
baseJson := map[string]interface{}{
baseJson := map[string]any{
// type is filled in by the test
"chainId": "0x7",
"nonce": "0x0",
@ -503,7 +503,7 @@ func TestYParityJSONUnmarshalling(t *testing.T) {
"maxFeePerBlobGas": "0x3b9aca00",
"value": "0x0",
"input": "0x",
"accessList": []interface{}{},
"accessList": []any{},
"blobVersionedHashes": []string{
"0x010657f37554c781402a22917dee2f75def7ab966d7b770905398eba3c444014",
},

View file

@ -46,7 +46,7 @@ func benchRLP(b *testing.B, encode bool) {
signer := NewLondonSigner(big.NewInt(1337))
for _, tc := range []struct {
name string
obj interface{}
obj any
}{
{
"legacy-header",

View file

@ -28,7 +28,7 @@ import (
func TestPush(t *testing.T) {
tests := []struct {
input interface{}
input any
expected string
}{
// native ints

View file

@ -23,7 +23,7 @@ import (
)
var stackPool = sync.Pool{
New: func() interface{} {
New: func() any {
return &Stack{data: make([]uint256.Int, 0, 16)}
},
}

View file

@ -77,7 +77,7 @@ func HashData(kh KeccakState, data []byte) (h common.Hash) {
// CreateAddress creates an ethereum address given the bytes and the nonce
func CreateAddress(b common.Address, nonce uint64) common.Address {
data, _ := rlp.EncodeToBytes([]interface{}{b, nonce})
data, _ := rlp.EncodeToBytes([]any{b, nonce})
return common.BytesToAddress(Keccak256(data)[12:])
}

View file

@ -99,7 +99,7 @@ func (api *DebugAPI) Preimage(ctx context.Context, hash common.Hash) (hexutil.By
// BadBlockArgs represents the entries in the list returned when bad blocks are queried.
type BadBlockArgs struct {
Hash common.Hash `json:"hash"`
Block map[string]interface{} `json:"block"`
Block map[string]any `json:"block"`
RLP string `json:"rlp"`
}
@ -113,7 +113,7 @@ func (api *DebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error)
for _, block := range blocks {
var (
blockRlp string
blockJSON map[string]interface{}
blockJSON map[string]any
)
if rlpBytes, err := rlp.EncodeToBytes(block); err != nil {
blockRlp = err.Error() // Hacky, but hey, it works
@ -447,7 +447,7 @@ func (api *DebugAPI) GetTrieFlushInterval() (string, error) {
// StateSize returns the current state size statistics from the state size tracker.
// Returns an error if the state size tracker is not initialized or if stats are not ready.
func (api *DebugAPI) StateSize(blockHashOrNumber *rpc.BlockNumberOrHash) (interface{}, error) {
func (api *DebugAPI) StateSize(blockHashOrNumber *rpc.BlockNumberOrHash) (any, error) {
sizer := api.eth.blockchain.StateSizer()
if sizer == nil {
return nil, errors.New("state size tracker is not enabled")
@ -477,7 +477,7 @@ func (api *DebugAPI) StateSize(blockHashOrNumber *rpc.BlockNumberOrHash) (interf
}
return nil, fmt.Errorf("state size of %s is not available", s)
}
return map[string]interface{}{
return map[string]any{
"stateRoot": stats.StateRoot,
"blockNumber": hexutil.Uint64(stats.BlockNumber),
"accounts": hexutil.Uint64(stats.Accounts),

View file

@ -370,7 +370,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
func makeExtraData(extra []byte) []byte {
if len(extra) == 0 {
// create default extradata
extra, _ = rlp.EncodeToBytes([]interface{}{
extra, _ = rlp.EncodeToBytes([]any{
uint(gethversion.Major<<16 | gethversion.Minor<<8 | gethversion.Patch),
"geth",
runtime.Version(),

View file

@ -250,12 +250,12 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl
finalized := api.remoteBlocks.get(update.FinalizedBlockHash)
// Header advertised via a past newPayload request. Start syncing to it.
context := []interface{}{"number", header.Number, "hash", header.Hash()}
context := []any{"number", header.Number, "hash", header.Hash()}
if update.FinalizedBlockHash != (common.Hash{}) {
if finalized == nil {
context = append(context, []interface{}{"finalized", "unknown"}...)
context = append(context, []any{"finalized", "unknown"}...)
} else {
context = append(context, []interface{}{"finalized", finalized.Number}...)
context = append(context, []any{"finalized", finalized.Number}...)
}
}
log.Info("Forkchoice requested sync to new head", context...)

View file

@ -34,7 +34,7 @@ type DownloaderAPI struct {
d *Downloader
chain *core.BlockChain
mux *event.TypeMux
installSyncSubscription chan chan interface{}
installSyncSubscription chan chan any
uninstallSyncSubscription chan *uninstallSyncSubscriptionRequest
}
@ -47,7 +47,7 @@ func NewDownloaderAPI(d *Downloader, chain *core.BlockChain, m *event.TypeMux) *
d: d,
chain: chain,
mux: m,
installSyncSubscription: make(chan chan interface{}),
installSyncSubscription: make(chan chan any),
uninstallSyncSubscription: make(chan *uninstallSyncSubscriptionRequest),
}
go api.eventLoop()
@ -67,7 +67,7 @@ func NewDownloaderAPI(d *Downloader, chain *core.BlockChain, m *event.TypeMux) *
func (api *DownloaderAPI) eventLoop() {
var (
sub = api.mux.Subscribe(StartEvent{})
syncSubscriptions = make(map[chan interface{}]struct{})
syncSubscriptions = make(map[chan any]struct{})
checkInterval = time.Second * 60
checkTimer = time.NewTimer(checkInterval)
@ -143,7 +143,7 @@ func (api *DownloaderAPI) Syncing(ctx context.Context) (*rpc.Subscription, error
rpcSub := notifier.CreateSubscription()
go func() {
statuses := make(chan interface{})
statuses := make(chan any)
sub := api.SubscribeSyncStatus(statuses)
defer sub.Unsubscribe()
@ -168,14 +168,14 @@ type SyncingResult struct {
// uninstallSyncSubscriptionRequest uninstalls a syncing subscription in the API event loop.
type uninstallSyncSubscriptionRequest struct {
c chan interface{}
uninstalled chan interface{}
c chan any
uninstalled chan any
}
// SyncStatusSubscription represents a syncing subscription.
type SyncStatusSubscription struct {
api *DownloaderAPI // register subscription in event loop of this api instance
c chan interface{} // channel where events are broadcasted to
c chan any // channel where events are broadcasted to
unsubOnce sync.Once // make sure unsubscribe logic is executed once
}
@ -184,7 +184,7 @@ type SyncStatusSubscription struct {
// after this method returns.
func (s *SyncStatusSubscription) Unsubscribe() {
s.unsubOnce.Do(func() {
req := uninstallSyncSubscriptionRequest{s.c, make(chan interface{})}
req := uninstallSyncSubscriptionRequest{s.c, make(chan any)}
s.api.uninstallSyncSubscription <- &req
for {
@ -201,7 +201,7 @@ func (s *SyncStatusSubscription) Unsubscribe() {
// SubscribeSyncStatus creates a subscription that will broadcast new synchronisation updates.
// The given channel must receive interface values, the result can either be a SyncingResult or false.
func (api *DownloaderAPI) SubscribeSyncStatus(status chan interface{}) *SyncStatusSubscription {
func (api *DownloaderAPI) SubscribeSyncStatus(status chan any) *SyncStatusSubscription {
api.installSyncSubscription <- status
return &SyncStatusSubscription{api: api, c: status}
}

View file

@ -355,15 +355,15 @@ func (q *queue) Results(block bool) []*fetchResult {
return results
}
func (q *queue) Stats() []interface{} {
func (q *queue) Stats() []any {
q.lock.RLock()
defer q.lock.RUnlock()
return q.stats()
}
func (q *queue) stats() []interface{} {
return []interface{}{
func (q *queue) stats() []any {
return []any{
"receiptTasks", q.receiptTaskQueue.Size(),
"blockTasks", q.blockTaskQueue.Size(),
"itemSize", q.resultSize,
@ -536,7 +536,7 @@ func (q *queue) ExpireReceipts(peer string) int {
// Note, this method expects the queue lock to be already held. The reason the
// lock is not obtained in here is that the parameters already need to access
// the queue, so they already need a lock anyway.
func (q *queue) expire(peer string, pendPool map[string]*fetchRequest, taskQueue interface{}) int {
func (q *queue) expire(peer string, pendPool map[string]*fetchRequest, taskQueue any) int {
// Retrieve the request being expired and log an error if it's non-existent,
// as there's no order of events that should lead to such expirations.
req := pendPool[peer]

View file

@ -1125,7 +1125,7 @@ func (s *skeleton) processResponse(res *headerResponse) (linked bool, merged boo
// the syncer's internal state is corrupted. Do try to fix it, but
// be very vocal about the fault.
default:
var context []interface{}
var context []any
for i := range s.progress.Subchains[1:] {
context = append(context, fmt.Sprintf("stale_head_%d", i+1))

View file

@ -15,7 +15,7 @@ import (
)
// MarshalTOML marshals as TOML.
func (c Config) MarshalTOML() (interface{}, error) {
func (c Config) MarshalTOML() (any, error) {
type Config struct {
Genesis *core.Genesis `toml:",omitempty"`
NetworkId uint64
@ -119,7 +119,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
}
// UnmarshalTOML unmarshals from TOML.
func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
func (c *Config) UnmarshalTOML(unmarshal func(any) error) error {
type Config struct {
Genesis *core.Genesis `toml:",omitempty"`
NetworkId *uint64

View file

@ -80,7 +80,7 @@ type isUnderpriced int
// runner.
type txFetcherTest struct {
init func() *TxFetcher
steps []interface{}
steps []any
}
// Tests that transaction announcements with associated metadata are added to a
@ -99,7 +99,7 @@ func TestTransactionFetcherWaiting(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Initial announcement to get something into the waitlist
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
isWaiting(map[string][]announce{
@ -301,7 +301,7 @@ func TestTransactionFetcherSkipWaiting(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Push an initial announcement through to the scheduled stage
doTxNotify{
peer: "A",
@ -391,7 +391,7 @@ func TestTransactionFetcherSingletonRequesting(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Push an initial announcement through to the scheduled stage
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
isWaiting(map[string][]announce{
@ -499,7 +499,7 @@ func TestTransactionFetcherFailedRescheduling(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Push an initial announcement through to the scheduled stage
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
isWaiting(map[string][]announce{
@ -582,7 +582,7 @@ func TestTransactionFetcherCleanup(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Push an initial announcement through to the scheduled stage
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
isWaiting(map[string][]announce{
@ -626,7 +626,7 @@ func TestTransactionFetcherCleanupEmpty(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Push an initial announcement through to the scheduled stage
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
isWaiting(map[string][]announce{
@ -669,7 +669,7 @@ func TestTransactionFetcherMissingRescheduling(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Push an initial announcement through to the scheduled stage
doTxNotify{peer: "A",
hashes: []common.Hash{testTxsHashes[0], testTxsHashes[1], testTxsHashes[2]},
@ -730,7 +730,7 @@ func TestTransactionFetcherMissingCleanup(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Push an initial announcement through to the scheduled stage
doTxNotify{peer: "A",
hashes: []common.Hash{testTxsHashes[0], testTxsHashes[1]},
@ -779,7 +779,7 @@ func TestTransactionFetcherBroadcasts(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Set up three transactions to be in different stats, waiting, queued and fetching
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
doWait{time: txArriveTimeout, step: true},
@ -833,7 +833,7 @@ func TestTransactionFetcherWaitTimerResets(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
isWaiting(map[string][]announce{
"A": {
@ -905,7 +905,7 @@ func TestTransactionFetcherTimeoutRescheduling(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Push an initial announcement through to the scheduled stage
doTxNotify{
peer: "A",
@ -981,7 +981,7 @@ func TestTransactionFetcherTimeoutTimerResets(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
doWait{time: txArriveTimeout, step: true},
doTxNotify{peer: "B", hashes: []common.Hash{{0x02}}, types: []byte{types.LegacyTxType}, sizes: []uint32{222}},
@ -1059,7 +1059,7 @@ func TestTransactionFetcherRateLimiting(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Announce all the transactions, wait a bit and ensure only a small
// percentage gets requested
doTxNotify{peer: "A", hashes: hashes, types: ts, sizes: sizes},
@ -1089,7 +1089,7 @@ func TestTransactionFetcherBandwidthLimiting(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Announce mid size transactions from A to verify that multiple
// ones can be piled into a single request.
doTxNotify{peer: "A",
@ -1206,7 +1206,7 @@ func TestTransactionFetcherDoSProtection(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Announce half of the transaction and wait for them to be scheduled
doTxNotify{peer: "A", hashes: hashesA[:maxTxAnnounces/2], types: typesA[:maxTxAnnounces/2], sizes: sizesA[:maxTxAnnounces/2]},
doTxNotify{peer: "B", hashes: hashesB[:maxTxAnnounces/2-1], types: typesB[:maxTxAnnounces/2-1], sizes: sizesB[:maxTxAnnounces/2-1]},
@ -1285,7 +1285,7 @@ func TestTransactionFetcherUnderpricedDedup(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Deliver a transaction through the fetcher, but reject as underpriced
doTxNotify{peer: "A",
hashes: []common.Hash{testTxsHashes[0], testTxsHashes[1]},
@ -1340,7 +1340,7 @@ func TestTransactionFetcherUnderpricedDoSProtection(t *testing.T) {
})
}
// Generate a set of steps to announce and deliver the entire set of transactions
var steps []interface{}
var steps []any
for i := 0; i < maxTxUnderpricedSetSize/maxTxRetrievals; i++ {
steps = append(steps, doTxNotify{
peer: "A",
@ -1380,7 +1380,7 @@ func TestTransactionFetcherUnderpricedDoSProtection(t *testing.T) {
nil,
)
},
steps: append(steps, []interface{}{
steps: append(steps, []any{
// The preparation of the test has already been done in `steps`, add the last check
doTxNotify{
peer: "A",
@ -1408,7 +1408,7 @@ func TestTransactionFetcherOutOfBoundDeliveries(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Deliver something out of the blue
isWaiting(nil),
isScheduled{nil, nil, nil},
@ -1467,7 +1467,7 @@ func TestTransactionFetcherDrop(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Set up a few hashes into various stages
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
doWait{time: txArriveTimeout, step: true},
@ -1541,7 +1541,7 @@ func TestTransactionFetcherDropRescheduling(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Set up a few hashes into various stages
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
doWait{time: txArriveTimeout, step: true},
@ -1587,7 +1587,7 @@ func TestInvalidAnnounceMetadata(t *testing.T) {
func(peer string) { drop <- peer },
)
},
steps: []interface{}{
steps: []any{
// Initial announcement to get something into the waitlist
doTxNotify{
peer: "A",
@ -1670,7 +1670,7 @@ func TestTransactionFetcherFuzzCrash01(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Get a transaction into fetching mode and make it dangling with a broadcast
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
doWait{time: txArriveTimeout, step: true},
@ -1698,7 +1698,7 @@ func TestTransactionFetcherFuzzCrash02(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Get a transaction into fetching mode and make it dangling with a broadcast
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
doWait{time: txArriveTimeout, step: true},
@ -1728,7 +1728,7 @@ func TestTransactionFetcherFuzzCrash03(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Get a transaction into fetching mode and make it dangling with a broadcast
doTxNotify{
peer: "A",
@ -1770,7 +1770,7 @@ func TestTransactionFetcherFuzzCrash04(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Get a transaction into fetching mode and make it dangling with a broadcast
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
doWait{time: txArriveTimeout, step: true},
@ -1800,7 +1800,7 @@ func TestBlobTransactionAnnounce(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
// Initial announcement to get something into the waitlist
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
isWaiting(map[string][]announce{
@ -1870,7 +1870,7 @@ func TestTransactionFetcherDropAlternates(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
doWait{time: txArriveTimeout, step: true},
doTxNotify{peer: "B", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
@ -1926,7 +1926,7 @@ func TestTransactionFetcherWrongMetadata(t *testing.T) {
nil,
)
},
steps: []interface{}{
steps: []any{
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{0xff, types.LegacyTxType}, sizes: []uint32{111, 222}},
isWaiting(map[string][]announce{
"A": {

View file

@ -365,7 +365,7 @@ func (api *FilterAPI) TransactionReceipts(ctx context.Context, filter *Transacti
case receiptsWithTxs := <-matchedReceipts:
if len(receiptsWithTxs) > 0 {
// Convert to the same format as eth_getTransactionReceipt
marshaledReceipts := make([]map[string]interface{}, len(receiptsWithTxs))
marshaledReceipts := make([]map[string]any, len(receiptsWithTxs))
for i, receiptWithTx := range receiptsWithTxs {
marshaledReceipts[i] = ethapi.MarshalReceipt(
receiptWithTx.Receipt,
@ -546,7 +546,7 @@ func (api *FilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*types.Lo
//
// For pending transaction and block filters the result is []common.Hash.
// (pending)Log filters return []Log.
func (api *FilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error) {
func (api *FilterAPI) GetFilterChanges(id rpc.ID) (any, error) {
api.filtersMu.Lock()
defer api.filtersMu.Unlock()
@ -589,7 +589,7 @@ func (api *FilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error) {
}
}
return []interface{}{}, errFilterNotFound
return []any{}, errFilterNotFound
}
// returnHashes is a helper that will return an empty hash array case the given hash array is nil,
@ -616,8 +616,8 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
BlockHash *common.Hash `json:"blockHash"`
FromBlock *rpc.BlockNumber `json:"fromBlock"`
ToBlock *rpc.BlockNumber `json:"toBlock"`
Addresses interface{} `json:"address"`
Topics []interface{} `json:"topics"`
Addresses any `json:"address"`
Topics []any `json:"topics"`
}
var raw input
@ -646,7 +646,7 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
if raw.Addresses != nil {
// raw.Address can contain a single address or an array of addresses
switch rawAddr := raw.Addresses.(type) {
case []interface{}:
case []any:
for i, addr := range rawAddr {
if strAddr, ok := addr.(string); ok {
addr, err := decodeAddress(strAddr)
@ -689,7 +689,7 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
}
args.Topics[i] = []common.Hash{top}
case []interface{}:
case []any:
// or case e.g. [null, "topic0", "topic1"]
if len(topic) > maxSubTopics {
return errExceedMaxTopics

View file

@ -39,7 +39,7 @@ func (h *ethHandler) RunPeer(peer *eth.Peer, hand eth.Handler) error {
}
// PeerInfo retrieves all known `eth` information about a peer.
func (h *ethHandler) PeerInfo(id enode.ID) interface{} {
func (h *ethHandler) PeerInfo(id enode.ID) any {
if p := h.peers.peer(id.String()); p != nil {
return p.info()
}

View file

@ -47,7 +47,7 @@ func (h *testEthHandler) Chain() *core.BlockChain { panic("no backi
func (h *testEthHandler) TxPool() eth.TxPool { panic("no backing tx pool") }
func (h *testEthHandler) AcceptTxs() bool { return true }
func (h *testEthHandler) RunPeer(*eth.Peer, eth.Handler) error { panic("not used in tests") }
func (h *testEthHandler) PeerInfo(enode.ID) interface{} { panic("not used in tests") }
func (h *testEthHandler) PeerInfo(enode.ID) any { panic("not used in tests") }
func (h *testEthHandler) Handle(peer *eth.Peer, packet eth.Packet) error {
switch packet := packet.(type) {

View file

@ -34,7 +34,7 @@ func (h *snapHandler) RunPeer(peer *snap.Peer, hand snap.Handler) error {
}
// PeerInfo retrieves all known `snap` information about a peer.
func (h *snapHandler) PeerInfo(id enode.ID) interface{} {
func (h *snapHandler) PeerInfo(id enode.ID) any {
if p := h.peers.peer(id.String()); p != nil {
if p.snapExt != nil {
return p.snapExt.info()

View file

@ -49,7 +49,7 @@ type Request struct {
code uint64 // Message code of the request packet
want uint64 // Message code of the response packet
data interface{} // Data content of the request packet
data any // Data content of the request packet
Peer string // Demultiplexer if cross-peer requests are batched together
Sent time.Time // Timestamp when the request was sent
@ -101,8 +101,8 @@ type Response struct {
code uint64 // Response packet type to cross validate with request
Req *Request // Original request to cross-reference with
Res interface{} // Remote response for the request query
Meta interface{} // Metadata generated locally on the receiver thread
Res any // Remote response for the request query
Meta any // Metadata generated locally on the receiver thread
Time time.Duration // Time it took for the request to be served
Done chan error // Channel to signal message handling to the reader
}
@ -138,7 +138,7 @@ func (p *Peer) dispatchRequest(req *Request) error {
// dispatchResponse fulfils a pending request and delivers it to the requested
// sink.
func (p *Peer) dispatchResponse(res *Response, metadata func() interface{}) error {
func (p *Peer) dispatchResponse(res *Response, metadata func() any) error {
resOp := &response{
res: res,
fail: make(chan error),

View file

@ -75,7 +75,7 @@ type Backend interface {
RunPeer(peer *Peer, handler Handler) error
// PeerInfo retrieves all known `eth` information about a peer.
PeerInfo(id enode.ID) interface{}
PeerInfo(id enode.ID) any
// Handle is a callback to be invoked when a data packet is received from
// the remote peer. Only packets not consumed by the protocol handler will
@ -113,10 +113,10 @@ func MakeProtocols(backend Backend, network uint64, disc enode.Iterator) []p2p.P
return Handle(backend, peer)
})
},
NodeInfo: func() interface{} {
NodeInfo: func() any {
return nodeInfo(backend.Chain(), network)
},
PeerInfo: func(id enode.ID) interface{} {
PeerInfo: func(id enode.ID) any {
return backend.PeerInfo(id)
},
DialCandidates: disc,
@ -162,7 +162,7 @@ func Handle(backend Backend, peer *Peer) error {
type msgHandler func(backend Backend, msg Decoder, peer *Peer) error
type Decoder interface {
Decode(val interface{}) error
Decode(val any) error
Time() time.Time
}

View file

@ -159,7 +159,7 @@ func (b *testBackend) RunPeer(peer *Peer, handler Handler) error {
// is omitted and we will just give control back to the handler.
return handler(peer)
}
func (b *testBackend) PeerInfo(enode.ID) interface{} { panic("not implemented") }
func (b *testBackend) PeerInfo(enode.ID) any { panic("not implemented") }
func (b *testBackend) AcceptTxs() bool {
return true
@ -554,7 +554,7 @@ type decoder struct {
msg []byte
}
func (d decoder) Decode(val interface{}) error {
func (d decoder) Decode(val any) error {
buffer := bytes.NewBuffer(d.msg)
s := rlp.NewStream(buffer, uint64(len(d.msg)))
return s.Decode(val)

View file

@ -356,7 +356,7 @@ func handleBlockHeaders(backend Backend, msg Decoder, peer *Peer) error {
if err := msg.Decode(res); err != nil {
return err
}
metadata := func() interface{} {
metadata := func() any {
hashes := make([]common.Hash, len(res.BlockHeadersRequest))
for i, header := range res.BlockHeadersRequest {
hashes[i] = header.Hash()
@ -376,7 +376,7 @@ func handleBlockBodies(backend Backend, msg Decoder, peer *Peer) error {
if err := msg.Decode(res); err != nil {
return err
}
metadata := func() interface{} {
metadata := func() any {
var (
txsHashes = make([]common.Hash, len(res.BlockBodiesResponse))
uncleHashes = make([]common.Hash, len(res.BlockBodiesResponse))
@ -412,7 +412,7 @@ func handleReceipts[L ReceiptsList](backend Backend, msg Decoder, peer *Peer) er
res.List[i].setBuffers(buffers)
}
metadata := func() interface{} {
metadata := func() any {
hasher := trie.NewStackTrie(nil)
hashes := make([]common.Hash, len(res.List))
for i := range res.List {

View file

@ -44,11 +44,11 @@ func testHandshake(t *testing.T, protocol uint) {
)
tests := []struct {
code uint64
data interface{}
data any
want error
}{
{
code: TransactionsMsg, data: []interface{}{},
code: TransactionsMsg, data: []any{},
want: errNoStatusMsg,
},
{

View file

@ -199,7 +199,7 @@ func TestMessages(t *testing.T) {
}
for i, tc := range []struct {
message interface{}
message any
want []byte
}{
{

View file

@ -76,7 +76,7 @@ type Backend interface {
RunPeer(peer *Peer, handler Handler) error
// PeerInfo retrieves all known `snap` information about a peer.
PeerInfo(id enode.ID) interface{}
PeerInfo(id enode.ID) any
// Handle is a callback to be invoked when a data packet is received from
// the remote peer. Only packets not consumed by the protocol handler will
@ -97,10 +97,10 @@ func MakeProtocols(backend Backend) []p2p.Protocol {
return Handle(backend, peer)
})
},
NodeInfo: func() interface{} {
NodeInfo: func() any {
return nodeInfo(backend.Chain())
},
PeerInfo: func(id enode.ID) interface{} {
PeerInfo: func(id enode.ID) any {
return backend.PeerInfo(id)
},
Attributes: []enr.Entry{&enrEntry{}},

View file

@ -60,7 +60,7 @@ func FuzzTrieNodes(f *testing.F) {
})
}
func doFuzz(input []byte, obj interface{}, code int) {
func doFuzz(input []byte, obj any, code int) {
bc := getChain()
defer bc.Stop()
fuzz.NewFromGoFuzz(input).Fuzz(obj)
@ -138,7 +138,7 @@ type dummyBackend struct {
func (d *dummyBackend) Chain() *core.BlockChain { return d.chain }
func (d *dummyBackend) RunPeer(*Peer, Handler) error { return nil }
func (d *dummyBackend) PeerInfo(enode.ID) interface{} { return "Foo" }
func (d *dummyBackend) PeerInfo(enode.ID) any { return "Foo" }
func (d *dummyBackend) Handle(*Peer, Packet) error { return nil }
type dummyRW struct {

View file

@ -181,7 +181,7 @@ type StdTraceConfig struct {
// txTraceResult is the result of a single transaction trace.
type txTraceResult struct {
TxHash common.Hash `json:"txHash"` // transaction hash
Result interface{} `json:"result,omitempty"` // Trace results produced by the tracer
Result any `json:"result,omitempty"` // Trace results produced by the tracer
Error string `json:"error,omitempty"` // Trace failure produced by the tracer
}
@ -863,7 +863,7 @@ func containsTx(block *types.Block, hash common.Hash) bool {
// TraceTransaction returns the structured logs created during the execution of EVM
// and returns them as a JSON object.
func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (any, error) {
found, _, blockHash, blockNumber, index := api.backend.GetCanonicalTransaction(hash)
if !found {
// Warn in case tx indexer is not done.
@ -911,7 +911,7 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
// after executing the specified block. However, if a transaction index is provided,
// the trace will be conducted on the state after executing the specified transaction
// within the specified block.
func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (interface{}, error) {
func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (any, error) {
// Try to retrieve the specified block
var (
err error
@ -1006,7 +1006,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
// traceTx configures a new tracer according to the provided configuration, and
// executes the given message in the provided environment. The return value will
// be tracer dependent.
func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig, precompiles vm.PrecompiledContracts) (interface{}, error) {
func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig, precompiles vm.PrecompiledContracts) (any, error) {
var (
tracer *Tracer
err error

View file

@ -176,7 +176,7 @@ func testFlatCallTracer(tracerName string, dirPath string, t *testing.T) {
// jsonEqualFlat is similar to reflect.DeepEqual, but does a 'bounce' via json prior to
// comparison
func jsonEqualFlat(x, y interface{}) bool {
func jsonEqualFlat(x, y any) bool {
xTrace := new([]flatCallTrace)
yTrace := new([]flatCallTrace)
if xj, err := json.Marshal(x); err == nil {

View file

@ -46,7 +46,7 @@ type account struct {
// prestateTracerTest defines a single test to check the stateDiff tracer against.
type prestateTracerTest struct {
tracerTestEnv
Result interface{} `json:"result"`
Result any `json:"result"`
}
func TestPrestateTracerLegacy(t *testing.T) {

View file

@ -643,7 +643,7 @@ func testSupplyTracer(t *testing.T, genesis *core.Genesis, gen func(b *core.Bloc
return output, chain, nil
}
func compareAsJSON(t *testing.T, expected interface{}, actual interface{}) {
func compareAsJSON(t *testing.T, expected any, actual any) {
t.Helper()
want, err := json.Marshal(expected)
if err != nil {

View file

@ -138,7 +138,7 @@ type rpcBlock struct {
Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"`
}
func (ec *Client) getBlock(ctx context.Context, method string, args ...interface{}) (*types.Block, error) {
func (ec *Client) getBlock(ctx context.Context, method string, args ...any) (*types.Block, error) {
var raw json.RawMessage
err := ec.c.CallContext(ctx, &raw, method, args...)
if err != nil {
@ -186,7 +186,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
for i := range reqs {
reqs[i] = rpc.BatchElem{
Method: "eth_getUncleByBlockHashAndIndex",
Args: []interface{}{body.Hash, hexutil.EncodeUint64(uint64(i))},
Args: []any{body.Hash, hexutil.EncodeUint64(uint64(i))},
Result: &uncles[i],
}
}
@ -774,8 +774,8 @@ func toBlockNumArg(number *big.Int) string {
return fmt.Sprintf("<invalid %d>", number)
}
func toCallArg(msg ethereum.CallMsg) interface{} {
arg := map[string]interface{}{
func toCallArg(msg ethereum.CallMsg) any {
arg := map[string]any{
"from": msg.From,
"to": msg.To,
}
@ -886,9 +886,9 @@ func (s SimulateBlock) MarshalJSON() ([]byte, error) {
type Alias struct {
BlockOverrides *ethereum.BlockOverrides `json:"blockOverrides,omitempty"`
StateOverrides map[common.Address]ethereum.OverrideAccount `json:"stateOverrides,omitempty"`
Calls []interface{} `json:"calls"`
Calls []any `json:"calls"`
}
calls := make([]interface{}, len(s.Calls))
calls := make([]any, len(s.Calls))
for i, call := range s.Calls {
calls[i] = toCallArg(call)
}

View file

@ -244,8 +244,8 @@ func toBlockNumArg(number *big.Int) string {
return fmt.Sprintf("<invalid %d>", number)
}
func toCallArg(msg ethereum.CallMsg) interface{} {
arg := map[string]interface{}{
func toCallArg(msg ethereum.CallMsg) any {
arg := map[string]any{
"from": msg.From,
"to": msg.To,
}

View file

@ -38,7 +38,7 @@ func TestToFilterArg(t *testing.T) {
for _, testCase := range []struct {
name string
input ethereum.FilterQuery
output interface{}
output any
err error
}{
{
@ -61,7 +61,7 @@ func TestToFilterArg(t *testing.T) {
ToBlock: big.NewInt(2),
Topics: [][]common.Hash{},
},
map[string]interface{}{
map[string]any{
"address": addresses,
"fromBlock": "0x1",
"toBlock": "0x2",
@ -75,7 +75,7 @@ func TestToFilterArg(t *testing.T) {
Addresses: addresses,
Topics: [][]common.Hash{},
},
map[string]interface{}{
map[string]any{
"address": addresses,
"fromBlock": "0x0",
"toBlock": "latest",
@ -91,7 +91,7 @@ func TestToFilterArg(t *testing.T) {
ToBlock: big.NewInt(-1),
Topics: [][]common.Hash{},
},
map[string]interface{}{
map[string]any{
"address": addresses,
"fromBlock": "pending",
"toBlock": "pending",
@ -106,7 +106,7 @@ func TestToFilterArg(t *testing.T) {
BlockHash: &blockHash,
Topics: [][]common.Hash{},
},
map[string]interface{}{
map[string]any{
"address": addresses,
"blockHash": blockHash,
"topics": [][]common.Hash{},

View file

@ -172,7 +172,7 @@ type AncientWriter interface {
// AncientWriteOp is given to the function argument of ModifyAncients.
type AncientWriteOp interface {
// Append adds an RLP-encoded item.
Append(kind string, number uint64, item interface{}) error
Append(kind string, number uint64, item any) error
// AppendRaw adds an item without RLP-encoding it.
AppendRaw(kind string, number uint64, item []byte) error

View file

@ -113,7 +113,7 @@ func NewCustom(file string, namespace string, customize func(options *opt.Option
options := configureOptions(customize)
logger := log.New("database", file)
usedCache := options.GetBlockCacheCapacity() + options.GetWriteBuffer()*2
logCtx := []interface{}{"cache", common.StorageSize(usedCache), "handles", options.GetOpenFilesCacheCapacity()}
logCtx := []any{"cache", common.StorageSize(usedCache), "handles", options.GetOpenFilesCacheCapacity()}
if options.ReadOnly {
logCtx = append(logCtx, "readonly", "true")
}

Some files were not shown because too many files have changed in this diff Show more