mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-21 14:14:30 +00:00
common: remove usage of deprecated function (#21610)
This commit is contained in:
parent
cf0c5c8cd2
commit
28739d7863
8 changed files with 23 additions and 29 deletions
|
|
@ -23,12 +23,12 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"math/big"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"reflect"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/common/hexutil"
|
||||
"github.com/XinFinOrg/XDPoSChain/common/math"
|
||||
"github.com/XinFinOrg/XDPoSChain/crypto"
|
||||
)
|
||||
|
|
@ -713,7 +713,7 @@ func TestABI_MethodById(t *testing.T) {
|
|||
}
|
||||
b := fmt.Sprintf("%v", m2)
|
||||
if a != b {
|
||||
t.Errorf("Method %v (id %v) not 'findable' by id in ABI", name, common.ToHex(m.Id()))
|
||||
t.Errorf("Method %v (id %v) not 'findable' by id in ABI", name, hexutil.Encode(m.Id()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,19 +17,9 @@
|
|||
// Package common contains various helper functions.
|
||||
package common
|
||||
|
||||
import "encoding/hex"
|
||||
|
||||
// ToHex returns the hex representation of b, prefixed with '0x'.
|
||||
// For empty slices, the return value is "0x0".
|
||||
//
|
||||
// Deprecated: use hexutil.Encode instead.
|
||||
func ToHex(b []byte) string {
|
||||
hex := Bytes2Hex(b)
|
||||
if len(hex) == 0 {
|
||||
hex = "0"
|
||||
}
|
||||
return "0x" + hex
|
||||
}
|
||||
import (
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
// FromHex returns the bytes represented by the hexadecimal string s.
|
||||
// s may be prefixed with "0x".
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/common/hexutil"
|
||||
"github.com/XinFinOrg/XDPoSChain/consensus"
|
||||
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/utils"
|
||||
"github.com/XinFinOrg/XDPoSChain/consensus/misc"
|
||||
|
|
@ -171,7 +172,7 @@ func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Heade
|
|||
for index, mn := range masterNodes {
|
||||
log.Error("[verifyHeader] masternode list during validator verification", "Masternode Address", mn.Hex(), "index", index)
|
||||
}
|
||||
log.Error("[verifyHeader] Error while verifying header validator signature", "BlockNumber", header.Number, "Hash", header.Hash().Hex(), "validator in hex", common.ToHex(header.Validator))
|
||||
log.Error("[verifyHeader] Error while verifying header validator signature", "BlockNumber", header.Number, "Hash", header.Hash().Hex(), "validator in hex", hexutil.Encode(header.Validator))
|
||||
return err
|
||||
}
|
||||
if !verified {
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ package blocksigner
|
|||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"math/rand"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind"
|
||||
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends"
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/common/hexutil"
|
||||
"github.com/XinFinOrg/XDPoSChain/core"
|
||||
"github.com/XinFinOrg/XDPoSChain/crypto"
|
||||
"github.com/XinFinOrg/XDPoSChain/params"
|
||||
|
|
@ -50,7 +50,7 @@ func TestBlockSigner(t *testing.T) {
|
|||
ctx, cancel := context.WithDeadline(context.Background(), d)
|
||||
defer cancel()
|
||||
code, _ := contractBackend.CodeAt(ctx, blockSignerAddress, nil)
|
||||
t.Log("contract code", common.ToHex(code))
|
||||
t.Log("contract code", hexutil.Encode(code))
|
||||
f := func(key, val common.Hash) bool {
|
||||
t.Log(key.Hex(), val.Hex())
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import (
|
|||
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind"
|
||||
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends"
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/common/hexutil"
|
||||
"github.com/XinFinOrg/XDPoSChain/contracts"
|
||||
"github.com/XinFinOrg/XDPoSChain/core"
|
||||
"github.com/XinFinOrg/XDPoSChain/core/types"
|
||||
|
|
@ -56,7 +57,7 @@ func TestRandomize(t *testing.T) {
|
|||
ctx, cancel := context.WithDeadline(context.Background(), d)
|
||||
defer cancel()
|
||||
code, _ := contractBackend.CodeAt(ctx, randomizeAddress, nil)
|
||||
t.Log("contract code", common.ToHex(code))
|
||||
t.Log("contract code", hexutil.Encode(code))
|
||||
f := func(key, val common.Hash) bool {
|
||||
t.Log(key.Hex(), val.Hex())
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind"
|
||||
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends"
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/common/hexutil"
|
||||
contractValidator "github.com/XinFinOrg/XDPoSChain/contracts/validator/contract"
|
||||
"github.com/XinFinOrg/XDPoSChain/core"
|
||||
"github.com/XinFinOrg/XDPoSChain/core/state"
|
||||
|
|
@ -68,7 +69,7 @@ func TestValidator(t *testing.T) {
|
|||
ctx, cancel := context.WithDeadline(context.Background(), d)
|
||||
defer cancel()
|
||||
code, _ := contractBackend.CodeAt(ctx, validatorAddress, nil)
|
||||
t.Log("contract code", common.ToHex(code))
|
||||
t.Log("contract code", hexutil.Encode(code))
|
||||
f := func(key, val common.Hash) bool {
|
||||
t.Log(key.Hex(), val.Hex())
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/common/hexutil"
|
||||
"github.com/XinFinOrg/XDPoSChain/common/math"
|
||||
"github.com/XinFinOrg/XDPoSChain/crypto"
|
||||
"github.com/XinFinOrg/XDPoSChain/rlp"
|
||||
|
|
@ -513,7 +514,7 @@ func (tx *Transaction) IsSigningTransaction() bool {
|
|||
if len(data) != (32*2 + 4) {
|
||||
return false
|
||||
}
|
||||
method := common.ToHex(data[0:4])
|
||||
method := hexutil.Encode(data[0:4])
|
||||
return method == common.SignMethod
|
||||
}
|
||||
|
||||
|
|
@ -524,7 +525,7 @@ func (tx *Transaction) IsVotingTransaction() (bool, *common.Address) {
|
|||
}
|
||||
var end int
|
||||
data := tx.Data()
|
||||
method := common.ToHex(data[0:4])
|
||||
method := hexutil.Encode(data[0:4])
|
||||
if method == common.VoteMethod || method == common.ProposeMethod || method == common.ResignMethod {
|
||||
end = len(data)
|
||||
} else if method == common.UnvoteMethod {
|
||||
|
|
@ -558,7 +559,7 @@ func (tx *Transaction) IsXDCXApplyTransaction() bool {
|
|||
if len(data) != (32 + 4) {
|
||||
return false
|
||||
}
|
||||
method := common.ToHex(data[0:4])
|
||||
method := hexutil.Encode(data[0:4])
|
||||
return method == common.XDCXApplyMethod
|
||||
}
|
||||
|
||||
|
|
@ -581,7 +582,7 @@ func (tx *Transaction) IsXDCZApplyTransaction() bool {
|
|||
if len(data) != (32 + 4) {
|
||||
return false
|
||||
}
|
||||
method := common.ToHex(data[0:4])
|
||||
method := hexutil.Encode(data[0:4])
|
||||
return method == common.XDCZApplyMethod
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) er
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ec.c.CallContext(ctx, nil, "eth_sendRawTransaction", common.ToHex(data))
|
||||
return ec.c.CallContext(ctx, nil, "eth_sendRawTransaction", hexutil.Encode(data))
|
||||
}
|
||||
|
||||
func toBlockNumArg(number *big.Int) string {
|
||||
|
|
@ -550,7 +550,7 @@ func (ec *Client) SendOrderTransaction(ctx context.Context, tx *types.OrderTrans
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ec.c.CallContext(ctx, nil, "XDCx_sendOrderRawTransaction", common.ToHex(data))
|
||||
return ec.c.CallContext(ctx, nil, "XDCx_sendOrderRawTransaction", hexutil.Encode(data))
|
||||
}
|
||||
|
||||
// SendLendingTransaction send lending to pool
|
||||
|
|
@ -559,7 +559,7 @@ func (ec *Client) SendLendingTransaction(ctx context.Context, tx *types.LendingT
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ec.c.CallContext(ctx, nil, "XDCx_sendLendingRawTransaction", common.ToHex(data))
|
||||
return ec.c.CallContext(ctx, nil, "XDCx_sendLendingRawTransaction", hexutil.Encode(data))
|
||||
}
|
||||
|
||||
func toCallArg(msg ethereum.CallMsg) interface{} {
|
||||
|
|
|
|||
Loading…
Reference in a new issue