all: remove redundant conversions and import names (#21903)

# Conflicts:
#	accounts/accounts.go
#	accounts/keystore/wallet.go
#	accounts/scwallet/wallet.go
#	accounts/usbwallet/wallet.go
#	cmd/clef/main.go
#	cmd/devp2p/dnscmd.go
#	cmd/evm/compiler.go
#	cmd/evm/disasm.go
#	cmd/evm/runner.go
#	cmd/evm/staterunner.go
#	cmd/geth/config.go
#	cmd/geth/main.go
#	cmd/geth/usage.go
#	cmd/utils/flags.go
#	consensus/ethash/ethash.go
#	core/state/statedb.go
#	core/tx_pool_test.go
#	core/vm/evm.go
#	core/vm/gas_table.go
#	core/vm/instructions.go
#	core/vm/operations_acl.go
#	eth/downloader/api.go
#	eth/filters/api.go
#	eth/filters/filter_system.go
#	eth/filters/filter_system_test.go
#	eth/tracers/tracer.go
#	internal/debug/flags.go
#	internal/ethapi/api.go
#	internal/flags/helpers.go
#	miner/unconfirmed_test.go
#	mobile/ethereum.go
#	trie/iterator.go
#	turbo/trie/database.go
This commit is contained in:
Alex Prut 2020-11-25 21:00:23 +01:00 committed by Igor Mandrigin
parent f981ed79b3
commit f032b6d18e
11 changed files with 24 additions and 24 deletions

View File

@ -202,12 +202,12 @@ func TestConvertType(t *testing.T) {
fields = append(fields, reflect.StructField{ fields = append(fields, reflect.StructField{
Name: "X", Name: "X",
Type: reflect.TypeOf(new(big.Int)), Type: reflect.TypeOf(new(big.Int)),
Tag: reflect.StructTag("json:\"" + "x" + "\""), Tag: "json:\"" + "x" + "\"",
}) })
fields = append(fields, reflect.StructField{ fields = append(fields, reflect.StructField{
Name: "Y", Name: "Y",
Type: reflect.TypeOf(new(big.Int)), Type: reflect.TypeOf(new(big.Int)),
Tag: reflect.StructTag("json:\"" + "y" + "\""), Tag: "json:\"" + "y" + "\"",
}) })
val := reflect.New(reflect.StructOf(fields)) val := reflect.New(reflect.StructOf(fields))
val.Elem().Field(0).Set(reflect.ValueOf(big.NewInt(1))) val.Elem().Field(0).Set(reflect.ValueOf(big.NewInt(1)))

View File

@ -255,7 +255,7 @@ func TestTypeCheck(t *testing.T) {
{"bytes", nil, [2]byte{0, 1}, "abi: cannot use array as type slice as argument"}, {"bytes", nil, [2]byte{0, 1}, "abi: cannot use array as type slice as argument"},
{"bytes", nil, common.Hash{1}, "abi: cannot use array as type slice as argument"}, {"bytes", nil, common.Hash{1}, "abi: cannot use array as type slice as argument"},
{"string", nil, "hello world", ""}, {"string", nil, "hello world", ""},
{"string", nil, string(""), ""}, {"string", nil, "", ""},
{"string", nil, []byte{}, "abi: cannot use slice as type string as argument"}, {"string", nil, []byte{}, "abi: cannot use slice as type string as argument"},
{"bytes32[]", nil, [][32]byte{{}}, ""}, {"bytes32[]", nil, [][32]byte{{}}, ""},
{"function", nil, [24]byte{}, ""}, {"function", nil, [24]byte{}, ""},

View File

@ -230,7 +230,7 @@ func DecryptKey(keyjson []byte, auth string) (*Key, error) {
key := crypto.ToECDSAUnsafe(keyBytes) key := crypto.ToECDSAUnsafe(keyBytes)
return &Key{ return &Key{
Id: uuid.UUID(keyId), Id: keyId,
Address: crypto.PubkeyToAddress(key.PublicKey), Address: crypto.PubkeyToAddress(key.PublicKey),
PrivateKey: key, PrivateKey: key,
}, nil }, nil

View File

@ -154,7 +154,7 @@ func newAlethGenesisSpec(network string, genesis *core.Genesis) (*alethGenesisSp
spec.Genesis.Author = genesis.Coinbase spec.Genesis.Author = genesis.Coinbase
spec.Genesis.Timestamp = (hexutil.Uint64)(genesis.Timestamp) spec.Genesis.Timestamp = (hexutil.Uint64)(genesis.Timestamp)
spec.Genesis.ParentHash = genesis.ParentHash spec.Genesis.ParentHash = genesis.ParentHash
spec.Genesis.ExtraData = (hexutil.Bytes)(genesis.ExtraData) spec.Genesis.ExtraData = genesis.ExtraData
spec.Genesis.GasLimit = (hexutil.Uint64)(genesis.GasLimit) spec.Genesis.GasLimit = (hexutil.Uint64)(genesis.GasLimit)
for address, account := range genesis.Alloc { for address, account := range genesis.Alloc {
@ -432,7 +432,7 @@ func newParityChainSpec(network string, genesis *core.Genesis, bootnodes []strin
spec.Genesis.Author = genesis.Coinbase spec.Genesis.Author = genesis.Coinbase
spec.Genesis.Timestamp = (hexutil.Uint64)(genesis.Timestamp) spec.Genesis.Timestamp = (hexutil.Uint64)(genesis.Timestamp)
spec.Genesis.ParentHash = genesis.ParentHash spec.Genesis.ParentHash = genesis.ParentHash
spec.Genesis.ExtraData = (hexutil.Bytes)(genesis.ExtraData) spec.Genesis.ExtraData = genesis.ExtraData
spec.Genesis.GasLimit = (hexutil.Uint64)(genesis.GasLimit) spec.Genesis.GasLimit = (hexutil.Uint64)(genesis.GasLimit)
spec.Accounts = make(map[common.UnprefixedAddress]*parityChainSpecAccount) spec.Accounts = make(map[common.UnprefixedAddress]*parityChainSpecAccount)

View File

@ -88,7 +88,7 @@ func TestUnmarshalBytes(t *testing.T) {
if !checkError(t, test.input, err, test.wantErr) { if !checkError(t, test.input, err, test.wantErr) {
continue continue
} }
if !bytes.Equal(test.want.([]byte), []byte(v)) { if !bytes.Equal(test.want.([]byte), v) {
t.Errorf("input %s: value mismatch: got %x, want %x", test.input, &v, test.want) t.Errorf("input %s: value mismatch: got %x, want %x", test.input, &v, test.want)
continue continue
} }

View File

@ -65,7 +65,7 @@ func (oracle *CheckpointOracle) LookupCheckpointEvents(blockLogs [][]*types.Log,
if err != nil { if err != nil {
continue continue
} }
if event.Index == section && common.Hash(event.CheckpointHash) == hash { if event.Index == section && event.CheckpointHash == hash {
votes = append(votes, event) votes = append(votes, event)
} }
} }

View File

@ -29,7 +29,7 @@ func TestSubCloseUnsub(t *testing.T) {
// the point of this test is **not** to panic // the point of this test is **not** to panic
var mux TypeMux var mux TypeMux
mux.Stop() mux.Stop()
sub := mux.Subscribe(int(0)) sub := mux.Subscribe(0)
sub.Unsubscribe() sub.Unsubscribe()
} }

View File

@ -27,8 +27,8 @@ import (
func TestFeedPanics(t *testing.T) { func TestFeedPanics(t *testing.T) {
{ {
var f Feed var f Feed
f.Send(int(2)) f.Send(2)
want := feedTypeError{op: "Send", got: reflect.TypeOf(uint64(0)), want: reflect.TypeOf(int(0))} want := feedTypeError{op: "Send", got: reflect.TypeOf(uint64(0)), want: reflect.TypeOf(0)}
if err := checkPanic(want, func() { f.Send(uint64(2)) }); err != nil { if err := checkPanic(want, func() { f.Send(uint64(2)) }); err != nil {
t.Error(err) t.Error(err)
} }
@ -37,14 +37,14 @@ func TestFeedPanics(t *testing.T) {
var f Feed var f Feed
ch := make(chan int) ch := make(chan int)
f.Subscribe(ch) f.Subscribe(ch)
want := feedTypeError{op: "Send", got: reflect.TypeOf(uint64(0)), want: reflect.TypeOf(int(0))} want := feedTypeError{op: "Send", got: reflect.TypeOf(uint64(0)), want: reflect.TypeOf(0)}
if err := checkPanic(want, func() { f.Send(uint64(2)) }); err != nil { if err := checkPanic(want, func() { f.Send(uint64(2)) }); err != nil {
t.Error(err) t.Error(err)
} }
} }
{ {
var f Feed var f Feed
f.Send(int(2)) f.Send(2)
want := feedTypeError{op: "Subscribe", got: reflect.TypeOf(make(chan uint64)), want: reflect.TypeOf(make(chan<- int))} want := feedTypeError{op: "Subscribe", got: reflect.TypeOf(make(chan uint64)), want: reflect.TypeOf(make(chan<- int))}
if err := checkPanic(want, func() { f.Subscribe(make(chan uint64)) }); err != nil { if err := checkPanic(want, func() { f.Subscribe(make(chan uint64)) }); err != nil {
t.Error(err) t.Error(err)
@ -58,7 +58,7 @@ func TestFeedPanics(t *testing.T) {
} }
{ {
var f Feed var f Feed
if err := checkPanic(errBadChannel, func() { f.Subscribe(int(0)) }); err != nil { if err := checkPanic(errBadChannel, func() { f.Subscribe(0) }); err != nil {
t.Error(err) t.Error(err)
} }
} }

View File

@ -79,7 +79,7 @@ func (a *Account) Code(ctx context.Context) (hexutil.Bytes, error) {
if err != nil { if err != nil {
return hexutil.Bytes{}, err return hexutil.Bytes{}, err
} }
return hexutil.Bytes(state.GetCode(a.address)), nil return state.GetCode(a.address), nil
} }
func (a *Account) Storage(ctx context.Context, args struct{ Slot common.Hash }) (common.Hash, error) { func (a *Account) Storage(ctx context.Context, args struct{ Slot common.Hash }) (common.Hash, error) {
@ -120,7 +120,7 @@ func (l *Log) Topics(ctx context.Context) []common.Hash {
} }
func (l *Log) Data(ctx context.Context) hexutil.Bytes { func (l *Log) Data(ctx context.Context) hexutil.Bytes {
return hexutil.Bytes(l.log.Data) return l.log.Data
} }
// Transaction represents an Ethereum transaction. // Transaction represents an Ethereum transaction.
@ -161,7 +161,7 @@ func (t *Transaction) InputData(ctx context.Context) (hexutil.Bytes, error) {
if err != nil || tx == nil { if err != nil || tx == nil {
return hexutil.Bytes{}, err return hexutil.Bytes{}, err
} }
return hexutil.Bytes(tx.Data()), nil return tx.Data(), nil
} }
func (t *Transaction) Gas(ctx context.Context) (hexutil.Uint64, error) { func (t *Transaction) Gas(ctx context.Context) (hexutil.Uint64, error) {
@ -414,7 +414,7 @@ func (b *Block) resolveReceipts(ctx context.Context) ([]*types.Receipt, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
b.receipts = []*types.Receipt(receipts) b.receipts = receipts
} }
return b.receipts, nil return b.receipts, nil
} }
@ -494,7 +494,7 @@ func (b *Block) Nonce(ctx context.Context) (hexutil.Bytes, error) {
if err != nil { if err != nil {
return hexutil.Bytes{}, err return hexutil.Bytes{}, err
} }
return hexutil.Bytes(header.Nonce[:]), nil return header.Nonce[:], nil
} }
func (b *Block) MixHash(ctx context.Context) (common.Hash, error) { func (b *Block) MixHash(ctx context.Context) (common.Hash, error) {
@ -568,7 +568,7 @@ func (b *Block) ExtraData(ctx context.Context) (hexutil.Bytes, error) {
if err != nil { if err != nil {
return hexutil.Bytes{}, err return hexutil.Bytes{}, err
} }
return hexutil.Bytes(header.Extra), nil return header.Extra, nil
} }
func (b *Block) LogsBloom(ctx context.Context) (hexutil.Bytes, error) { func (b *Block) LogsBloom(ctx context.Context) (hexutil.Bytes, error) {
@ -576,7 +576,7 @@ func (b *Block) LogsBloom(ctx context.Context) (hexutil.Bytes, error) {
if err != nil { if err != nil {
return hexutil.Bytes{}, err return hexutil.Bytes{}, err
} }
return hexutil.Bytes(header.Bloom.Bytes()), nil return header.Bloom.Bytes(), nil
} }
func (b *Block) TotalDifficulty(ctx context.Context) (hexutil.Big, error) { func (b *Block) TotalDifficulty(ctx context.Context) (hexutil.Big, error) {
@ -911,7 +911,7 @@ func (r *Resolver) Block(ctx context.Context, args struct {
}) (*Block, error) { }) (*Block, error) {
var block *Block var block *Block
if args.Number != nil { if args.Number != nil {
number := rpc.BlockNumber(uint64(*args.Number)) number := rpc.BlockNumber(*args.Number)
numberOrHash := rpc.BlockNumberOrHashWithNumber(number) numberOrHash := rpc.BlockNumberOrHashWithNumber(number)
block = &Block{ block = &Block{
backend: r.backend, backend: r.backend,

View File

@ -171,7 +171,7 @@ func splitNodeItemKey(key []byte) (id ID, ip net.IP, field string) {
} }
key = key[len(dbDiscoverRoot)+1:] key = key[len(dbDiscoverRoot)+1:]
// Split out the IP. // Split out the IP.
ip = net.IP(key[:16]) ip = key[:16]
if ip4 := ip.To4(); ip4 != nil { if ip4 := ip.To4(); ip4 != nil {
ip = ip4 ip = ip4
} }

View File

@ -506,7 +506,7 @@ func parseBytes(encType interface{}) ([]byte, bool) {
case []byte: case []byte:
return v, true return v, true
case hexutil.Bytes: case hexutil.Bytes:
return []byte(v), true return v, true
case string: case string:
bytes, err := hexutil.Decode(v) bytes, err := hexutil.Decode(v)
if err != nil { if err != nil {