diff options
author | Jeffrey Wilcke <obscuren@users.noreply.github.com> | 2014-07-01 22:16:05 +0800 |
---|---|---|
committer | Jeffrey Wilcke <obscuren@users.noreply.github.com> | 2014-07-01 22:16:05 +0800 |
commit | 29f613ef84ed39ccc1929dd1069f3576ade889f1 (patch) | |
tree | 0c12e6fe9e0214989401bb47a6d4503081fd47bc /ethchain/block.go | |
parent | 550407b0ec78b7026737d1abe28127da8c0c9063 (diff) | |
parent | ff5703fd9b089de67811af61de05637c62dc7a2c (diff) | |
download | go-tangerine-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar go-tangerine-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar.gz go-tangerine-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar.bz2 go-tangerine-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar.lz go-tangerine-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar.xz go-tangerine-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar.zst go-tangerine-29f613ef84ed39ccc1929dd1069f3576ade889f1.zip |
Merge pull request #28 from ethersphere/feature/keys
Feature/keys
Diffstat (limited to 'ethchain/block.go')
-rw-r--r-- | ethchain/block.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ethchain/block.go b/ethchain/block.go index 1be8282fa..a0f9ecd86 100644 --- a/ethchain/block.go +++ b/ethchain/block.go @@ -3,6 +3,8 @@ package ethchain import ( "bytes" "fmt" + "github.com/ethereum/eth-go/ethcrypto" + "github.com/ethereum/eth-go/ethtrie" "github.com/ethereum/eth-go/ethutil" "math/big" "strconv" @@ -102,18 +104,18 @@ func CreateBlock(root interface{}, } block.SetUncles([]*Block{}) - block.state = NewState(ethutil.NewTrie(ethutil.Config.Db, root)) + block.state = NewState(ethtrie.NewTrie(ethutil.Config.Db, root)) return block } // Returns a hash of the block func (block *Block) Hash() []byte { - return ethutil.Sha3Bin(block.Value().Encode()) + return ethcrypto.Sha3Bin(block.Value().Encode()) } func (block *Block) HashNoNonce() []byte { - return ethutil.Sha3Bin(ethutil.Encode([]interface{}{block.PrevHash, + return ethcrypto.Sha3Bin(ethutil.Encode([]interface{}{block.PrevHash, block.UncleSha, block.Coinbase, block.state.trie.Root, block.TxSha, block.Difficulty, block.Number, block.MinGasPrice, block.GasLimit, block.GasUsed, block.Time, block.Extra})) @@ -239,7 +241,7 @@ func (block *Block) SetUncles(uncles []*Block) { block.Uncles = uncles // Sha of the concatenated uncles - block.UncleSha = ethutil.Sha3Bin(ethutil.Encode(block.rlpUncles())) + block.UncleSha = ethcrypto.Sha3Bin(ethutil.Encode(block.rlpUncles())) } func (self *Block) SetReceipts(receipts []*Receipt, txs []*Transaction) { @@ -250,7 +252,7 @@ func (self *Block) SetReceipts(receipts []*Receipt, txs []*Transaction) { func (block *Block) setTransactions(txs []*Transaction) { block.transactions = txs - trie := ethutil.NewTrie(ethutil.Config.Db, "") + trie := ethtrie.NewTrie(ethutil.Config.Db, "") for i, tx := range txs { trie.Update(strconv.Itoa(i), string(tx.RlpEncode())) } @@ -287,7 +289,7 @@ func (block *Block) RlpValueDecode(decoder *ethutil.Value) { block.PrevHash = header.Get(0).Bytes() block.UncleSha = header.Get(1).Bytes() block.Coinbase = header.Get(2).Bytes() - block.state = NewState(ethutil.NewTrie(ethutil.Config.Db, header.Get(3).Val)) + block.state = NewState(ethtrie.NewTrie(ethutil.Config.Db, header.Get(3).Val)) block.TxSha = header.Get(4).Bytes() block.Difficulty = header.Get(5).BigInt() block.Number = header.Get(6).BigInt() @@ -329,7 +331,7 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block { block.PrevHash = header.Get(0).Bytes() block.UncleSha = header.Get(1).Bytes() block.Coinbase = header.Get(2).Bytes() - block.state = NewState(ethutil.NewTrie(ethutil.Config.Db, header.Get(3).Val)) + block.state = NewState(ethtrie.NewTrie(ethutil.Config.Db, header.Get(3).Val)) block.TxSha = header.Get(4).Bytes() block.Difficulty = header.Get(5).BigInt() block.Number = header.Get(6).BigInt() |