Skip to content

Commit b523441

Browse files
committed
Moved ethutil => common
1 parent 0b8f66e commit b523441

116 files changed

Lines changed: 610 additions & 604 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎accounts/abi/numbers.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"math/big"
55
"reflect"
66

7-
"github.com/ethereum/go-ethereum/ethutil"
7+
"github.com/ethereum/go-ethereum/common"
88
)
99

1010
var big_t = reflect.TypeOf(&big.Int{})
@@ -38,13 +38,13 @@ var big_ts = reflect.TypeOf([]*big.Int(nil))
3838

3939
// U256 will ensure unsigned 256bit on big nums
4040
func U256(n *big.Int) []byte {
41-
return ethutil.LeftPadBytes(ethutil.U256(n).Bytes(), 32)
41+
return common.LeftPadBytes(common.U256(n).Bytes(), 32)
4242
}
4343

4444
func S256(n *big.Int) []byte {
45-
sint := ethutil.S256(n)
46-
ret := ethutil.LeftPadBytes(sint.Bytes(), 32)
47-
if sint.Cmp(ethutil.Big0) < 0 {
45+
sint := common.S256(n)
46+
ret := common.LeftPadBytes(sint.Bytes(), 32)
47+
if sint.Cmp(common.Big0) < 0 {
4848
for i, b := range ret {
4949
if b == 0 {
5050
ret[i] = 1

‎accounts/abi/type.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"regexp"
77
"strconv"
88

9-
"github.com/ethereum/go-ethereum/ethutil"
9+
"github.com/ethereum/go-ethereum/common"
1010
)
1111

1212
const (
@@ -157,15 +157,15 @@ func (t Type) pack(v interface{}) ([]byte, error) {
157157
if t.Size > -1 && value.Len() > t.Size {
158158
return nil, fmt.Errorf("%v out of bound. %d for %d", value.Kind(), value.Len(), t.Size)
159159
}
160-
return []byte(ethutil.LeftPadString(t.String(), 32)), nil
160+
return []byte(common.LeftPadString(t.String(), 32)), nil
161161
case reflect.Slice:
162162
if t.Size > -1 && value.Len() > t.Size {
163163
return nil, fmt.Errorf("%v out of bound. %d for %d", value.Kind(), value.Len(), t.Size)
164164
}
165165

166166
// Address is a special slice. The slice acts as one rather than a list of elements.
167167
if t.T == AddressTy {
168-
return ethutil.LeftPadBytes(v.([]byte), 32), nil
168+
return common.LeftPadBytes(v.([]byte), 32), nil
169169
}
170170

171171
// Signed / Unsigned check
@@ -180,9 +180,9 @@ func (t Type) pack(v interface{}) ([]byte, error) {
180180
return packed, nil
181181
case reflect.Bool:
182182
if value.Bool() {
183-
return ethutil.LeftPadBytes(ethutil.Big1.Bytes(), 32), nil
183+
return common.LeftPadBytes(common.Big1.Bytes(), 32), nil
184184
} else {
185-
return ethutil.LeftPadBytes(ethutil.Big0.Bytes(), 32), nil
185+
return common.LeftPadBytes(common.Big0.Bytes(), 32), nil
186186
}
187187
}
188188

‎blockpool/blockpool_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/ethereum/go-ethereum/blockpool/test"
88
"github.com/ethereum/go-ethereum/core/types"
9-
"github.com/ethereum/go-ethereum/ethutil"
9+
"github.com/ethereum/go-ethereum/common"
1010
)
1111

1212
func TestPeerWithKnownBlock(t *testing.T) {
@@ -69,9 +69,9 @@ func TestPeerPromotionByOptionalTdOnBlock(t *testing.T) {
6969
hashes := blockPoolTester.hashPool.IndexesToHashes([]int{2, 3})
7070
peer1.waitBlocksRequests(3)
7171
blockPool.AddBlock(&types.Block{
72-
HeaderHash: ethutil.Bytes(hashes[1]),
73-
ParentHeaderHash: ethutil.Bytes(hashes[0]),
74-
Td: ethutil.Big3,
72+
HeaderHash: common.Bytes(hashes[1]),
73+
ParentHeaderHash: common.Bytes(hashes[0]),
74+
Td: common.Big3,
7575
}, "peer1")
7676

7777
blockPool.RemovePeer("peer2")

‎blockpool/blockpool_util_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/ethereum/go-ethereum/blockpool/test"
1111
"github.com/ethereum/go-ethereum/core/types"
1212
"github.com/ethereum/go-ethereum/errs"
13-
"github.com/ethereum/go-ethereum/ethutil"
13+
"github.com/ethereum/go-ethereum/common"
1414
"github.com/ethereum/go-ethereum/pow"
1515
)
1616

@@ -315,7 +315,7 @@ func (self *peerTester) sendBlocks(indexes ...int) {
315315
hashes := self.hashPool.IndexesToHashes(indexes)
316316
for i := 1; i < len(hashes); i++ {
317317
fmt.Printf("adding block %v %x\n", indexes[i], hashes[i][:4])
318-
self.blockPool.AddBlock(&types.Block{HeaderHash: ethutil.Bytes(hashes[i]), ParentHeaderHash: ethutil.Bytes(hashes[i-1])}, self.id)
318+
self.blockPool.AddBlock(&types.Block{HeaderHash: common.Bytes(hashes[i]), ParentHeaderHash: common.Bytes(hashes[i-1])}, self.id)
319319
}
320320
}
321321

‎blockpool/peers.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"github.com/ethereum/go-ethereum/core/types"
1212
"github.com/ethereum/go-ethereum/errs"
13-
"github.com/ethereum/go-ethereum/ethutil"
13+
"github.com/ethereum/go-ethereum/common"
1414
)
1515

1616
type peer struct {
@@ -230,7 +230,7 @@ func (self *peers) addPeer(
230230
}
231231
best = true
232232
} else {
233-
currentTD := ethutil.Big0
233+
currentTD := common.Big0
234234
if self.best != nil {
235235
currentTD = self.best.td
236236
}
@@ -264,7 +264,7 @@ func (self *peers) removePeer(id string) {
264264
if self.best == p {
265265
var newp *peer
266266
// FIXME: own TD
267-
max := ethutil.Big0
267+
max := common.Big0
268268
// peer with the highest self-acclaimed TD is chosen
269269
for _, pp := range self.peers {
270270
if pp.td.Cmp(max) > 0 {

‎cmd/disasm/main.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"io/ioutil"
66
"os"
77

8-
"github.com/ethereum/go-ethereum/ethutil"
8+
"github.com/ethereum/go-ethereum/common"
99
"github.com/ethereum/go-ethereum/vm"
1010
)
1111

@@ -15,7 +15,7 @@ func main() {
1515
fmt.Println(err)
1616
os.Exit(1)
1717
}
18-
code = ethutil.Hex2Bytes(string(code[:len(code)-1]))
18+
code = common.Hex2Bytes(string(code[:len(code)-1]))
1919
fmt.Printf("%x\n", code)
2020

2121
for pc := uint64(0); pc < uint64(len(code)); pc++ {

‎cmd/ethereum/blocktest.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/ethereum/go-ethereum/cmd/utils"
88
"github.com/ethereum/go-ethereum/eth"
99
"github.com/ethereum/go-ethereum/ethdb"
10-
"github.com/ethereum/go-ethereum/ethutil"
10+
"github.com/ethereum/go-ethereum/common"
1111
"github.com/ethereum/go-ethereum/tests"
1212
)
1313

@@ -41,7 +41,7 @@ func runblocktest(ctx *cli.Context) {
4141
}
4242

4343
cfg := utils.MakeEthConfig(ClientIdentifier, Version, ctx)
44-
cfg.NewDB = func(path string) (ethutil.Database, error) { return ethdb.NewMemDatabase() }
44+
cfg.NewDB = func(path string) (common.Database, error) { return ethdb.NewMemDatabase() }
4545
ethereum, err := eth.New(cfg)
4646
if err != nil {
4747
utils.Fatalf("%v", err)

‎cmd/ethereum/js.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
"github.com/ethereum/go-ethereum/core/types"
2929
"github.com/ethereum/go-ethereum/eth"
30-
"github.com/ethereum/go-ethereum/ethutil"
30+
"github.com/ethereum/go-ethereum/common"
3131
"github.com/ethereum/go-ethereum/javascript"
3232
"github.com/ethereum/go-ethereum/state"
3333
"github.com/ethereum/go-ethereum/xeth"
@@ -226,7 +226,7 @@ func (self *jsre) dump(call otto.FunctionCall) otto.Value {
226226
block = self.ethereum.ChainManager().GetBlockByNumber(uint64(num))
227227
} else if call.Argument(0).IsString() {
228228
hash, _ := call.Argument(0).ToString()
229-
block = self.ethereum.ChainManager().GetBlock(ethutil.Hex2Bytes(hash))
229+
block = self.ethereum.ChainManager().GetBlock(common.Hex2Bytes(hash))
230230
} else {
231231
fmt.Println("invalid argument for dump. Either hex string or number")
232232
}
@@ -285,7 +285,7 @@ func (self *jsre) export(call otto.FunctionCall) otto.Value {
285285

286286
data := self.ethereum.ChainManager().Export()
287287

288-
if err := ethutil.WriteFile(fn, data); err != nil {
288+
if err := common.WriteFile(fn, data); err != nil {
289289
fmt.Println(err)
290290
return otto.FalseValue()
291291
}

‎cmd/ethereum/main.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"github.com/ethereum/go-ethereum/cmd/utils"
3434
"github.com/ethereum/go-ethereum/core/types"
3535
"github.com/ethereum/go-ethereum/eth"
36-
"github.com/ethereum/go-ethereum/ethutil"
36+
"github.com/ethereum/go-ethereum/common"
3737
"github.com/ethereum/go-ethereum/logger"
3838
"github.com/ethereum/go-ethereum/state"
3939
"github.com/peterh/liner"
@@ -200,7 +200,7 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
200200
}
201201
am := eth.AccountManager()
202202
// Attempt to unlock the account
203-
err := am.Unlock(ethutil.FromHex(split[0]), split[1])
203+
err := am.Unlock(common.FromHex(split[0]), split[1])
204204
if err != nil {
205205
utils.Fatalf("Unlock account failed '%v'", err)
206206
}
@@ -284,7 +284,7 @@ func dump(ctx *cli.Context) {
284284
for _, arg := range ctx.Args() {
285285
var block *types.Block
286286
if hashish(arg) {
287-
block = chainmgr.GetBlock(ethutil.Hex2Bytes(arg))
287+
block = chainmgr.GetBlock(common.Hex2Bytes(arg))
288288
} else {
289289
num, _ := strconv.Atoi(arg)
290290
block = chainmgr.GetBlockByNumber(uint64(num))

0 commit comments

Comments
 (0)