diff options
author | obscuren <geffobscura@gmail.com> | 2014-07-21 18:21:34 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-07-21 18:21:34 +0800 |
commit | 5d2669dbd35b9449cbbb249dcec89e2a64c90f30 (patch) | |
tree | e12a934fa2408210458a65c282aac815e21d4708 /ethchain/block.go | |
parent | 9f00aeae29d53fec358fcecdc9bcc162b8e3984c (diff) | |
download | go-tangerine-5d2669dbd35b9449cbbb249dcec89e2a64c90f30.tar go-tangerine-5d2669dbd35b9449cbbb249dcec89e2a64c90f30.tar.gz go-tangerine-5d2669dbd35b9449cbbb249dcec89e2a64c90f30.tar.bz2 go-tangerine-5d2669dbd35b9449cbbb249dcec89e2a64c90f30.tar.lz go-tangerine-5d2669dbd35b9449cbbb249dcec89e2a64c90f30.tar.xz go-tangerine-5d2669dbd35b9449cbbb249dcec89e2a64c90f30.tar.zst go-tangerine-5d2669dbd35b9449cbbb249dcec89e2a64c90f30.zip |
Fixed tx sha creation
Diffstat (limited to 'ethchain/block.go')
-rw-r--r-- | ethchain/block.go | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/ethchain/block.go b/ethchain/block.go index a0f9ecd86..447d55f99 100644 --- a/ethchain/block.go +++ b/ethchain/block.go @@ -7,7 +7,7 @@ import ( "github.com/ethereum/eth-go/ethtrie" "github.com/ethereum/eth-go/ethutil" "math/big" - "strconv" + _ "strconv" "time" ) @@ -252,20 +252,43 @@ func (self *Block) SetReceipts(receipts []*Receipt, txs []*Transaction) { func (block *Block) setTransactions(txs []*Transaction) { block.transactions = txs + /* + trie := ethtrie.NewTrie(ethutil.Config.Db, "") + for i, tx := range txs { + trie.Update(strconv.Itoa(i), string(tx.RlpEncode())) + } + + switch trie.Root.(type) { + case string: + block.TxSha = []byte(trie.Root.(string)) + case []byte: + block.TxSha = trie.Root.([]byte) + default: + panic(fmt.Sprintf("invalid root type %T", trie.Root)) + } + */ +} + +func CreateTxSha(receipts Receipts) (sha []byte) { trie := ethtrie.NewTrie(ethutil.Config.Db, "") - for i, tx := range txs { - trie.Update(strconv.Itoa(i), string(tx.RlpEncode())) + for i, receipt := range receipts { + trie.Update(string(ethutil.NewValue(i).Encode()), string(ethutil.NewValue(receipt.RlpData()).Encode())) } switch trie.Root.(type) { case string: - block.TxSha = []byte(trie.Root.(string)) + sha = []byte(trie.Root.(string)) case []byte: - block.TxSha = trie.Root.([]byte) + sha = trie.Root.([]byte) default: panic(fmt.Sprintf("invalid root type %T", trie.Root)) } + return sha +} + +func (self *Block) SetTxHash(receipts Receipts) { + self.TxSha = CreateTxSha(receipts) } func (block *Block) Value() *ethutil.Value { |