aboutsummaryrefslogtreecommitdiffstats
path: root/core/types
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 /core/types
parent0b8f66ed9ef177dc72442dd7ba337c6733e30344 (diff)
downloaddexon-b5234413611ce5984292f85a01de1f56c045b490.tar
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.gz
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.bz2
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.lz
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.xz
dexon-b5234413611ce5984292f85a01de1f56c045b490.tar.zst
dexon-b5234413611ce5984292f85a01de1f56c045b490.zip
Moved ethutil => common
Diffstat (limited to 'core/types')
-rw-r--r--core/types/block.go10
-rw-r--r--core/types/bloom9.go8
-rw-r--r--core/types/bloom9_test.go4
-rw-r--r--core/types/derive_sha.go4
-rw-r--r--core/types/receipt.go14
-rw-r--r--core/types/transaction.go18
6 files changed, 29 insertions, 29 deletions
diff --git a/core/types/block.go b/core/types/block.go
index ba6ef6014..2d65cdca6 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -9,7 +9,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/rlp"
)
@@ -74,11 +74,11 @@ func (self *Header) RlpData() interface{} {
}
func (self *Header) Hash() []byte {
- return crypto.Sha3(ethutil.Encode(self.rlpData(true)))
+ return crypto.Sha3(common.Encode(self.rlpData(true)))
}
func (self *Header) HashNoNonce() []byte {
- return crypto.Sha3(ethutil.Encode(self.rlpData(false)))
+ return crypto.Sha3(common.Encode(self.rlpData(false)))
}
type Block struct {
@@ -148,7 +148,7 @@ func (self *Block) Uncles() []*Header {
func (self *Block) SetUncles(uncleHeaders []*Header) {
self.uncles = uncleHeaders
- self.header.UncleHash = crypto.Sha3(ethutil.Encode(uncleHeaders))
+ self.header.UncleHash = crypto.Sha3(common.Encode(uncleHeaders))
}
func (self *Block) Transactions() Transactions {
@@ -213,7 +213,7 @@ func (self *Block) GasLimit() *big.Int { return self.header.GasLimit }
func (self *Block) GasUsed() *big.Int { return self.header.GasUsed }
func (self *Block) Root() []byte { return self.header.Root }
func (self *Block) SetRoot(root []byte) { self.header.Root = root }
-func (self *Block) Size() ethutil.StorageSize { return ethutil.StorageSize(len(ethutil.Encode(self))) }
+func (self *Block) Size() common.StorageSize { return common.StorageSize(len(common.Encode(self))) }
func (self *Block) GetTransaction(i int) *Transaction {
if len(self.transactions) > i {
return self.transactions[i]
diff --git a/core/types/bloom9.go b/core/types/bloom9.go
index 578265a34..af76f226f 100644
--- a/core/types/bloom9.go
+++ b/core/types/bloom9.go
@@ -4,7 +4,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/state"
)
@@ -14,7 +14,7 @@ func CreateBloom(receipts Receipts) []byte {
bin.Or(bin, LogsBloom(receipt.logs))
}
- return ethutil.LeftPadBytes(bin.Bytes(), 256)
+ return common.LeftPadBytes(bin.Bytes(), 256)
}
func LogsBloom(logs state.Logs) *big.Int {
@@ -28,7 +28,7 @@ func LogsBloom(logs state.Logs) *big.Int {
}
for _, b := range data {
- bin.Or(bin, ethutil.BigD(bloom9(crypto.Sha3(b)).Bytes()))
+ bin.Or(bin, common.BigD(bloom9(crypto.Sha3(b)).Bytes()))
}
}
@@ -48,7 +48,7 @@ func bloom9(b []byte) *big.Int {
}
func BloomLookup(bin, topic []byte) bool {
- bloom := ethutil.BigD(bin)
+ bloom := common.BigD(bin)
cmp := bloom9(crypto.Sha3(topic))
return bloom.And(bloom, cmp).Cmp(cmp) == 0
diff --git a/core/types/bloom9_test.go b/core/types/bloom9_test.go
index 74e00cac6..0841bb859 100644
--- a/core/types/bloom9_test.go
+++ b/core/types/bloom9_test.go
@@ -22,10 +22,10 @@ func TestBloom9(t *testing.T) {
func TestAddress(t *testing.T) {
block := &Block{}
- block.Coinbase = ethutil.Hex2Bytes("22341ae42d6dd7384bc8584e50419ea3ac75b83f")
+ block.Coinbase = common.Hex2Bytes("22341ae42d6dd7384bc8584e50419ea3ac75b83f")
fmt.Printf("%x\n", crypto.Sha3(block.Coinbase))
bin := CreateBloom(block)
- fmt.Printf("bin = %x\n", ethutil.LeftPadBytes(bin, 64))
+ fmt.Printf("bin = %x\n", common.LeftPadBytes(bin, 64))
}
*/
diff --git a/core/types/derive_sha.go b/core/types/derive_sha.go
index b2c442210..593a31f1c 100644
--- a/core/types/derive_sha.go
+++ b/core/types/derive_sha.go
@@ -2,7 +2,7 @@ package types
import (
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/trie"
)
@@ -15,7 +15,7 @@ func DeriveSha(list DerivableList) []byte {
db, _ := ethdb.NewMemDatabase()
trie := trie.New(nil, db)
for i := 0; i < list.Len(); i++ {
- trie.Update(ethutil.Encode(i), list.GetRlp(i))
+ trie.Update(common.Encode(i), list.GetRlp(i))
}
return trie.Root()
diff --git a/core/types/receipt.go b/core/types/receipt.go
index 49e68e233..be14d0e0e 100644
--- a/core/types/receipt.go
+++ b/core/types/receipt.go
@@ -5,7 +5,7 @@ import (
"fmt"
"math/big"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/state"
)
@@ -17,10 +17,10 @@ type Receipt struct {
}
func NewReceipt(root []byte, cumalativeGasUsed *big.Int) *Receipt {
- return &Receipt{PostState: ethutil.CopyBytes(root), CumulativeGasUsed: new(big.Int).Set(cumalativeGasUsed)}
+ return &Receipt{PostState: common.CopyBytes(root), CumulativeGasUsed: new(big.Int).Set(cumalativeGasUsed)}
}
-func NewRecieptFromValue(val *ethutil.Value) *Receipt {
+func NewRecieptFromValue(val *common.Value) *Receipt {
r := &Receipt{}
r.RlpValueDecode(val)
@@ -31,7 +31,7 @@ func (self *Receipt) SetLogs(logs state.Logs) {
self.logs = logs
}
-func (self *Receipt) RlpValueDecode(decoder *ethutil.Value) {
+func (self *Receipt) RlpValueDecode(decoder *common.Value) {
self.PostState = decoder.Get(0).Bytes()
self.CumulativeGasUsed = decoder.Get(1).BigInt()
self.Bloom = decoder.Get(2).Bytes()
@@ -47,7 +47,7 @@ func (self *Receipt) RlpData() interface{} {
}
func (self *Receipt) RlpEncode() []byte {
- return ethutil.Encode(self.RlpData())
+ return common.Encode(self.RlpData())
}
func (self *Receipt) Cmp(other *Receipt) bool {
@@ -74,8 +74,8 @@ func (self Receipts) RlpData() interface{} {
}
func (self Receipts) RlpEncode() []byte {
- return ethutil.Encode(self.RlpData())
+ return common.Encode(self.RlpData())
}
func (self Receipts) Len() int { return len(self) }
-func (self Receipts) GetRlp(i int) []byte { return ethutil.Rlp(self[i]) }
+func (self Receipts) GetRlp(i int) []byte { return common.Rlp(self[i]) }
diff --git a/core/types/transaction.go b/core/types/transaction.go
index 88a718f93..dcd48af11 100644
--- a/core/types/transaction.go
+++ b/core/types/transaction.go
@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
)
@@ -42,7 +42,7 @@ func NewTransactionFromBytes(data []byte) *Transaction {
return tx
}
-func NewTransactionFromAmount(val *ethutil.Value) *Transaction {
+func NewTransactionFromAmount(val *common.Value) *Transaction {
tx := &Transaction{}
tx.RlpValueDecode(val)
@@ -52,7 +52,7 @@ func NewTransactionFromAmount(val *ethutil.Value) *Transaction {
func (tx *Transaction) Hash() []byte {
data := []interface{}{tx.AccountNonce, tx.Price, tx.GasLimit, tx.Recipient, tx.Amount, tx.Payload}
- return crypto.Sha3(ethutil.Encode(data))
+ return crypto.Sha3(common.Encode(data))
}
func (self *Transaction) Data() []byte {
@@ -89,8 +89,8 @@ func (self *Transaction) To() []byte {
func (tx *Transaction) Curve() (v byte, r []byte, s []byte) {
v = byte(tx.V)
- r = ethutil.LeftPadBytes(tx.R, 32)
- s = ethutil.LeftPadBytes(tx.S, 32)
+ r = common.LeftPadBytes(tx.R, 32)
+ s = common.LeftPadBytes(tx.S, 32)
return
}
@@ -159,14 +159,14 @@ func (tx *Transaction) RlpData() interface{} {
}
func (tx *Transaction) RlpEncode() []byte {
- return ethutil.Encode(tx)
+ return common.Encode(tx)
}
func (tx *Transaction) RlpDecode(data []byte) {
rlp.Decode(bytes.NewReader(data), tx)
}
-func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) {
+func (tx *Transaction) RlpValueDecode(decoder *common.Value) {
tx.AccountNonce = decoder.Get(0).Uint()
tx.Price = decoder.Get(1).BigInt()
tx.GasLimit = decoder.Get(2).BigInt()
@@ -206,7 +206,7 @@ func (tx *Transaction) String() string {
tx.V,
tx.R,
tx.S,
- ethutil.Encode(tx),
+ common.Encode(tx),
)
}
@@ -225,7 +225,7 @@ func (self Transactions) RlpData() interface{} {
}
func (s Transactions) Len() int { return len(s) }
func (s Transactions) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
-func (s Transactions) GetRlp(i int) []byte { return ethutil.Rlp(s[i]) }
+func (s Transactions) GetRlp(i int) []byte { return common.Rlp(s[i]) }
type TxByNonce struct{ Transactions }