aboutsummaryrefslogtreecommitdiffstats
path: root/xeth
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-16 18:27:38 +0800
committerobscuren <geffobscura@gmail.com>2015-03-16 18:27:38 +0800
commitb5234413611ce5984292f85a01de1f56c045b490 (patch)
treee6e0c6f7fe8358a2dc63cdea11ac66b4f59397f5 /xeth
parent0b8f66ed9ef177dc72442dd7ba337c6733e30344 (diff)
downloadgo-tangerine-b5234413611ce5984292f85a01de1f56c045b490.tar
go-tangerine-b5234413611ce5984292f85a01de1f56c045b490.tar.gz
go-tangerine-b5234413611ce5984292f85a01de1f56c045b490.tar.bz2
go-tangerine-b5234413611ce5984292f85a01de1f56c045b490.tar.lz
go-tangerine-b5234413611ce5984292f85a01de1f56c045b490.tar.xz
go-tangerine-b5234413611ce5984292f85a01de1f56c045b490.tar.zst
go-tangerine-b5234413611ce5984292f85a01de1f56c045b490.zip
Moved ethutil => common
Diffstat (limited to 'xeth')
-rw-r--r--xeth/state.go8
-rw-r--r--xeth/types.go30
-rw-r--r--xeth/whisper.go14
-rw-r--r--xeth/xeth.go56
4 files changed, 54 insertions, 54 deletions
diff --git a/xeth/state.go b/xeth/state.go
index bb729db33..7d9ceab1b 100644
--- a/xeth/state.go
+++ b/xeth/state.go
@@ -1,7 +1,7 @@
package xeth
import (
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/state"
)
@@ -19,7 +19,7 @@ func (self *State) State() *state.StateDB {
}
func (self *State) Get(addr string) *Object {
- return &Object{self.state.GetStateObject(ethutil.FromHex(addr))}
+ return &Object{self.state.GetStateObject(common.FromHex(addr))}
}
func (self *State) SafeGet(addr string) *Object {
@@ -27,9 +27,9 @@ func (self *State) SafeGet(addr string) *Object {
}
func (self *State) safeGet(addr string) *state.StateObject {
- object := self.state.GetStateObject(ethutil.FromHex(addr))
+ object := self.state.GetStateObject(common.FromHex(addr))
if object == nil {
- object = state.NewStateObject(ethutil.FromHex(addr), self.xeth.eth.StateDb())
+ object = state.NewStateObject(common.FromHex(addr), self.xeth.eth.StateDb())
}
return object
diff --git a/xeth/types.go b/xeth/types.go
index 3dc25a2ea..e15305481 100644
--- a/xeth/types.go
+++ b/xeth/types.go
@@ -8,14 +8,14 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/state"
)
func toHex(b []byte) string {
- return "0x" + ethutil.Bytes2Hex(b)
+ return "0x" + common.Bytes2Hex(b)
}
type Object struct {
@@ -26,20 +26,20 @@ func NewObject(state *state.StateObject) *Object {
return &Object{state}
}
-func (self *Object) StorageString(str string) *ethutil.Value {
- if ethutil.IsHex(str) {
- return self.storage(ethutil.Hex2Bytes(str[2:]))
+func (self *Object) StorageString(str string) *common.Value {
+ if common.IsHex(str) {
+ return self.storage(common.Hex2Bytes(str[2:]))
} else {
- return self.storage(ethutil.RightPadBytes([]byte(str), 32))
+ return self.storage(common.RightPadBytes([]byte(str), 32))
}
}
-func (self *Object) StorageValue(addr *ethutil.Value) *ethutil.Value {
+func (self *Object) StorageValue(addr *common.Value) *common.Value {
return self.storage(addr.Bytes())
}
-func (self *Object) storage(addr []byte) *ethutil.Value {
- return self.StateObject.GetStorage(ethutil.BigD(addr))
+func (self *Object) storage(addr []byte) *common.Value {
+ return self.StateObject.GetStorage(common.BigD(addr))
}
func (self *Object) Storage() (storage map[string]string) {
@@ -62,8 +62,8 @@ type Block struct {
Size string `json:"size"`
Number int `json:"number"`
Hash string `json:"hash"`
- Transactions *ethutil.List `json:"transactions"`
- Uncles *ethutil.List `json:"uncles"`
+ Transactions *common.List `json:"transactions"`
+ Uncles *common.List `json:"uncles"`
Time int64 `json:"time"`
Coinbase string `json:"coinbase"`
Name string `json:"name"`
@@ -84,13 +84,13 @@ func NewBlock(block *types.Block) *Block {
for i, tx := range block.Transactions() {
ptxs[i] = NewTx(tx)
}
- txlist := ethutil.NewList(ptxs)
+ txlist := common.NewList(ptxs)
puncles := make([]*Block, len(block.Uncles()))
for i, uncle := range block.Uncles() {
puncles[i] = NewBlock(types.NewBlockWithHeader(uncle))
}
- ulist := ethutil.NewList(puncles)
+ ulist := common.NewList(puncles)
return &Block{
ref: block, Size: block.Size().String(),
@@ -114,7 +114,7 @@ func (self *Block) ToString() string {
}
func (self *Block) GetTransaction(hash string) *Transaction {
- tx := self.ref.Transaction(ethutil.FromHex(hash))
+ tx := self.ref.Transaction(common.FromHex(hash))
if tx == nil {
return nil
}
@@ -154,7 +154,7 @@ func NewTx(tx *types.Transaction) *Transaction {
data = toHex(tx.Data())
}
- return &Transaction{ref: tx, Hash: hash, Value: ethutil.CurrencyToString(tx.Value()), Address: receiver, Contract: createsContract, Gas: tx.Gas().String(), GasPrice: tx.GasPrice().String(), Data: data, Sender: sender, CreatesContract: createsContract, RawData: toHex(tx.Data())}
+ return &Transaction{ref: tx, Hash: hash, Value: common.CurrencyToString(tx.Value()), Address: receiver, Contract: createsContract, Gas: tx.Gas().String(), GasPrice: tx.GasPrice().String(), Data: data, Sender: sender, CreatesContract: createsContract, RawData: toHex(tx.Data())}
}
func (self *Transaction) ToString() string {
diff --git a/xeth/whisper.go b/xeth/whisper.go
index f5c26faae..76bf8012a 100644
--- a/xeth/whisper.go
+++ b/xeth/whisper.go
@@ -5,7 +5,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/whisper"
)
@@ -29,12 +29,12 @@ func (self *Whisper) Post(payload string, to, from string, topics []string, prio
ttl = 100
}
- pk := crypto.ToECDSAPub(ethutil.FromHex(from))
+ pk := crypto.ToECDSAPub(common.FromHex(from))
if key := self.Whisper.GetIdentity(pk); key != nil || len(from) == 0 {
- msg := whisper.NewMessage(ethutil.FromHex(payload))
+ msg := whisper.NewMessage(common.FromHex(payload))
envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{
Ttl: time.Duration(ttl) * time.Second,
- To: crypto.ToECDSAPub(ethutil.FromHex(to)),
+ To: crypto.ToECDSAPub(common.FromHex(to)),
From: key,
Topics: whisper.TopicsFromString(topics...),
})
@@ -60,13 +60,13 @@ func (self *Whisper) NewIdentity() string {
}
func (self *Whisper) HasIdentity(key string) bool {
- return self.Whisper.HasIdentity(crypto.ToECDSAPub(ethutil.FromHex(key)))
+ return self.Whisper.HasIdentity(crypto.ToECDSAPub(common.FromHex(key)))
}
func (self *Whisper) Watch(opts *Options) int {
filter := whisper.Filter{
- To: crypto.ToECDSAPub(ethutil.FromHex(opts.To)),
- From: crypto.ToECDSAPub(ethutil.FromHex(opts.From)),
+ To: crypto.ToECDSAPub(common.FromHex(opts.To)),
+ From: crypto.ToECDSAPub(common.FromHex(opts.From)),
Topics: whisper.TopicsFromString(opts.Topics...),
}
diff --git a/xeth/xeth.go b/xeth/xeth.go
index cf500cd59..6c7a26c04 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -11,7 +11,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/p2p"
@@ -30,9 +30,9 @@ type Backend interface {
PeerCount() int
IsListening() bool
Peers() []*p2p.Peer
- BlockDb() ethutil.Database
- StateDb() ethutil.Database
- ExtraDb() ethutil.Database
+ BlockDb() common.Database
+ StateDb() common.Database
+ ExtraDb() common.Database
EventMux() *event.TypeMux
Whisper() *whisper.Whisper
@@ -116,21 +116,21 @@ func (self *XEth) State() *State { return self.state }
func (self *XEth) Whisper() *Whisper { return self.whisper }
func (self *XEth) BlockByHash(strHash string) *Block {
- hash := ethutil.FromHex(strHash)
+ hash := common.FromHex(strHash)
block := self.chainManager.GetBlock(hash)
return NewBlock(block)
}
func (self *XEth) EthBlockByHash(strHash string) *types.Block {
- hash := ethutil.FromHex(strHash)
+ hash := common.FromHex(strHash)
block := self.chainManager.GetBlock(hash)
return block
}
func (self *XEth) EthTransactionByHash(hash string) *types.Transaction {
- data, _ := self.eth.ExtraDb().Get(ethutil.FromHex(hash))
+ data, _ := self.eth.ExtraDb().Get(common.FromHex(hash))
if len(data) != 0 {
return types.NewTransactionFromBytes(data)
}
@@ -205,9 +205,9 @@ func (self *XEth) Coinbase() string {
}
func (self *XEth) NumberToHuman(balance string) string {
- b := ethutil.Big(balance)
+ b := common.Big(balance)
- return ethutil.CurrencyToString(b)
+ return common.CurrencyToString(b)
}
func (self *XEth) StorageAt(addr, storageAddr string) string {
@@ -233,7 +233,7 @@ func (self *XEth) IsContract(address string) bool {
}
func (self *XEth) SecretToAddress(key string) string {
- pair, err := crypto.NewKeyPairFromSec(ethutil.FromHex(key))
+ pair, err := crypto.NewKeyPairFromSec(common.FromHex(key))
if err != nil {
return ""
}
@@ -263,29 +263,29 @@ func (self *XEth) EachStorage(addr string) string {
}
func (self *XEth) ToAscii(str string) string {
- padded := ethutil.RightPadBytes([]byte(str), 32)
+ padded := common.RightPadBytes([]byte(str), 32)
return "0x" + toHex(padded)
}
func (self *XEth) FromAscii(str string) string {
- if ethutil.IsHex(str) {
+ if common.IsHex(str) {
str = str[2:]
}
- return string(bytes.Trim(ethutil.FromHex(str), "\x00"))
+ return string(bytes.Trim(common.FromHex(str), "\x00"))
}
func (self *XEth) FromNumber(str string) string {
- if ethutil.IsHex(str) {
+ if common.IsHex(str) {
str = str[2:]
}
- return ethutil.BigD(ethutil.FromHex(str)).String()
+ return common.BigD(common.FromHex(str)).String()
}
func (self *XEth) PushTx(encodedTx string) (string, error) {
- tx := types.NewTransactionFromBytes(ethutil.FromHex(encodedTx))
+ tx := types.NewTransactionFromBytes(common.FromHex(encodedTx))
err := self.eth.TxPool().Add(tx)
if err != nil {
return "", err
@@ -306,12 +306,12 @@ var (
func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) {
statedb := self.State().State() //self.chainManager.TransState()
msg := callmsg{
- from: statedb.GetOrNewStateObject(ethutil.FromHex(fromStr)),
- to: ethutil.FromHex(toStr),
- gas: ethutil.Big(gasStr),
- gasPrice: ethutil.Big(gasPriceStr),
- value: ethutil.Big(valueStr),
- data: ethutil.FromHex(dataStr),
+ from: statedb.GetOrNewStateObject(common.FromHex(fromStr)),
+ to: common.FromHex(toStr),
+ gas: common.Big(gasStr),
+ gasPrice: common.Big(gasPriceStr),
+ value: common.Big(valueStr),
+ data: common.FromHex(dataStr),
}
if msg.gas.Cmp(big.NewInt(0)) == 0 {
msg.gas = defaultGas
@@ -332,16 +332,16 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt
var (
from []byte
to []byte
- value = ethutil.NewValue(valueStr)
- gas = ethutil.NewValue(gasStr)
- price = ethutil.NewValue(gasPriceStr)
+ value = common.NewValue(valueStr)
+ gas = common.NewValue(gasStr)
+ price = common.NewValue(gasPriceStr)
data []byte
contractCreation bool
)
- from = ethutil.FromHex(fromStr)
- data = ethutil.FromHex(codeStr)
- to = ethutil.FromHex(toStr)
+ from = common.FromHex(fromStr)
+ data = common.FromHex(codeStr)
+ to = common.FromHex(toStr)
if len(to) == 0 {
contractCreation = true
}