@@ -3,6 +3,8 @@ package ethchain
33import (
44 "bytes"
55 "fmt"
6+ "github.com/ethereum/eth-go/ethcrypto"
7+ "github.com/ethereum/eth-go/ethtrie"
68 "github.com/ethereum/eth-go/ethutil"
79 "math/big"
810 "strconv"
@@ -102,18 +104,18 @@ func CreateBlock(root interface{},
102104 }
103105 block .SetUncles ([]* Block {})
104106
105- block .state = NewState (ethutil .NewTrie (ethutil .Config .Db , root ))
107+ block .state = NewState (ethtrie .NewTrie (ethutil .Config .Db , root ))
106108
107109 return block
108110}
109111
110112// Returns a hash of the block
111113func (block * Block ) Hash () []byte {
112- return ethutil .Sha3Bin (block .Value ().Encode ())
114+ return ethcrypto .Sha3Bin (block .Value ().Encode ())
113115}
114116
115117func (block * Block ) HashNoNonce () []byte {
116- return ethutil .Sha3Bin (ethutil .Encode ([]interface {}{block .PrevHash ,
118+ return ethcrypto .Sha3Bin (ethutil .Encode ([]interface {}{block .PrevHash ,
117119 block .UncleSha , block .Coinbase , block .state .trie .Root ,
118120 block .TxSha , block .Difficulty , block .Number , block .MinGasPrice ,
119121 block .GasLimit , block .GasUsed , block .Time , block .Extra }))
@@ -239,7 +241,7 @@ func (block *Block) SetUncles(uncles []*Block) {
239241 block .Uncles = uncles
240242
241243 // Sha of the concatenated uncles
242- block .UncleSha = ethutil .Sha3Bin (ethutil .Encode (block .rlpUncles ()))
244+ block .UncleSha = ethcrypto .Sha3Bin (ethutil .Encode (block .rlpUncles ()))
243245}
244246
245247func (self * Block ) SetReceipts (receipts []* Receipt , txs []* Transaction ) {
@@ -250,7 +252,7 @@ func (self *Block) SetReceipts(receipts []*Receipt, txs []*Transaction) {
250252func (block * Block ) setTransactions (txs []* Transaction ) {
251253 block .transactions = txs
252254
253- trie := ethutil .NewTrie (ethutil .Config .Db , "" )
255+ trie := ethtrie .NewTrie (ethutil .Config .Db , "" )
254256 for i , tx := range txs {
255257 trie .Update (strconv .Itoa (i ), string (tx .RlpEncode ()))
256258 }
@@ -287,7 +289,7 @@ func (block *Block) RlpValueDecode(decoder *ethutil.Value) {
287289 block .PrevHash = header .Get (0 ).Bytes ()
288290 block .UncleSha = header .Get (1 ).Bytes ()
289291 block .Coinbase = header .Get (2 ).Bytes ()
290- block .state = NewState (ethutil .NewTrie (ethutil .Config .Db , header .Get (3 ).Val ))
292+ block .state = NewState (ethtrie .NewTrie (ethutil .Config .Db , header .Get (3 ).Val ))
291293 block .TxSha = header .Get (4 ).Bytes ()
292294 block .Difficulty = header .Get (5 ).BigInt ()
293295 block .Number = header .Get (6 ).BigInt ()
@@ -329,7 +331,7 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block {
329331 block .PrevHash = header .Get (0 ).Bytes ()
330332 block .UncleSha = header .Get (1 ).Bytes ()
331333 block .Coinbase = header .Get (2 ).Bytes ()
332- block .state = NewState (ethutil .NewTrie (ethutil .Config .Db , header .Get (3 ).Val ))
334+ block .state = NewState (ethtrie .NewTrie (ethutil .Config .Db , header .Get (3 ).Val ))
333335 block .TxSha = header .Get (4 ).Bytes ()
334336 block .Difficulty = header .Get (5 ).BigInt ()
335337 block .Number = header .Get (6 ).BigInt ()
0 commit comments