mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
common: remove BytesToBig
This commit is contained in:
parent
746e59c1e2
commit
b362fc9abd
5 changed files with 10 additions and 17 deletions
|
|
@ -30,16 +30,8 @@ var (
|
|||
Big257 = big.NewInt(257)
|
||||
)
|
||||
|
||||
// Bytes2Big
|
||||
func BytesToBig(data []byte) *big.Int {
|
||||
n := new(big.Int)
|
||||
n.SetBytes(data)
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func Bytes2Big(data []byte) *big.Int {
|
||||
return BytesToBig(data)
|
||||
return new(big.Int).SetBytes(data)
|
||||
}
|
||||
|
||||
func String2Big(num string) *big.Int {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import (
|
|||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
)
|
||||
|
|
@ -60,7 +59,7 @@ func (b *Bloom) Add(d *big.Int) {
|
|||
|
||||
// Big converts b to a big integer.
|
||||
func (b Bloom) Big() *big.Int {
|
||||
return common.Bytes2Big(b[:])
|
||||
return new(big.Int).SetBytes(b[:])
|
||||
}
|
||||
|
||||
func (b Bloom) Bytes() []byte {
|
||||
|
|
@ -72,7 +71,8 @@ func (b Bloom) Test(test *big.Int) bool {
|
|||
}
|
||||
|
||||
func (b Bloom) TestBytes(test []byte) bool {
|
||||
return b.Test(common.BytesToBig(test))
|
||||
return b.Test(new(big.Int).SetBytes(test))
|
||||
|
||||
}
|
||||
|
||||
// MarshalJSON encodes b as a hex string with 0x prefix.
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package vm
|
|||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
|
|
@ -69,8 +70,8 @@ func (c *ecrecover) Run(in []byte) []byte {
|
|||
// "in" is (hash, v, r, s), each 32 bytes
|
||||
// but for ecrecover we want (r, s, v)
|
||||
|
||||
r := common.BytesToBig(in[64:96])
|
||||
s := common.BytesToBig(in[96:128])
|
||||
r := new(big.Int).SetBytes(in[64:96])
|
||||
s := new(big.Int).SetBytes(in[96:128])
|
||||
v := in[63] - 27
|
||||
|
||||
// tighter sig s values in homestead only apply to tx sigs
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ func opSha3(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Sta
|
|||
evm.StateDB.AddPreimage(common.BytesToHash(hash), data)
|
||||
}
|
||||
|
||||
stack.push(common.BytesToBig(hash))
|
||||
stack.push(new(big.Int).SetBytes(hash))
|
||||
|
||||
evm.interpreter.intPool.put(offset, size)
|
||||
return nil, nil
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func TestExecute(t *testing.T) {
|
|||
t.Fatal("didn't expect error", err)
|
||||
}
|
||||
|
||||
num := common.BytesToBig(ret)
|
||||
num := new(big.Int).SetBytes(ret)
|
||||
if num.Cmp(big.NewInt(10)) != 0 {
|
||||
t.Error("Expected 10, got", num)
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ func TestCall(t *testing.T) {
|
|||
t.Fatal("didn't expect error", err)
|
||||
}
|
||||
|
||||
num := common.BytesToBig(ret)
|
||||
num := new(big.Int).SetBytes(ret)
|
||||
if num.Cmp(big.NewInt(10)) != 0 {
|
||||
t.Error("Expected 10, got", num)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue