aboutsummaryrefslogtreecommitdiffstats
path: root/chain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-11-14 21:17:54 +0800
committerobscuren <geffobscura@gmail.com>2014-11-14 21:17:54 +0800
commit56aa24002de357c24a9644a49d5702c8d4663909 (patch)
tree7791c7cbe4e66137cf85a405cf32751a7916ce70 /chain
parent711be7009ef5b9ad77f37a4ccd0dffcc9286e1f8 (diff)
downloadgo-tangerine-56aa24002de357c24a9644a49d5702c8d4663909.tar
go-tangerine-56aa24002de357c24a9644a49d5702c8d4663909.tar.gz
go-tangerine-56aa24002de357c24a9644a49d5702c8d4663909.tar.bz2
go-tangerine-56aa24002de357c24a9644a49d5702c8d4663909.tar.lz
go-tangerine-56aa24002de357c24a9644a49d5702c8d4663909.tar.xz
go-tangerine-56aa24002de357c24a9644a49d5702c8d4663909.tar.zst
go-tangerine-56aa24002de357c24a9644a49d5702c8d4663909.zip
Clean up
Diffstat (limited to 'chain')
-rw-r--r--chain/block.go2
-rw-r--r--chain/block_manager.go20
-rw-r--r--chain/bloom9.go8
-rw-r--r--chain/receipt.go6
4 files changed, 16 insertions, 20 deletions
diff --git a/chain/block.go b/chain/block.go
index 23a7c63a2..a4ab560dc 100644
--- a/chain/block.go
+++ b/chain/block.go
@@ -238,7 +238,7 @@ func (block *Block) SetUncles(uncles []*Block) {
func (self *Block) SetReceipts(receipts Receipts) {
self.receipts = receipts
self.ReceiptSha = DeriveSha(receipts)
- self.LogsBloom = CreateBloom(self)
+ self.LogsBloom = CreateBloom(receipts)
}
func (self *Block) SetTransactions(txs Transactions) {
diff --git a/chain/block_manager.go b/chain/block_manager.go
index d39f188d4..efe9e0862 100644
--- a/chain/block_manager.go
+++ b/chain/block_manager.go
@@ -159,8 +159,8 @@ done:
txGas.Sub(txGas, st.gas)
cumulative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas))
- bloom := ethutil.LeftPadBytes(LogsBloom(state.Logs()).Bytes(), 64)
- receipt := &Receipt{ethutil.CopyBytes(state.Root()), cumulative, bloom, state.Logs()}
+ receipt := &Receipt{ethutil.CopyBytes(state.Root()), cumulative, nil /*bloom*/, state.Logs()}
+ receipt.Bloom = CreateBloom(Receipts{receipt})
// Notify all subscribers
go self.eth.EventMux().Post(TxPostEvent{tx})
@@ -217,38 +217,38 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
txSha := DeriveSha(block.transactions)
if bytes.Compare(txSha, block.TxSha) != 0 {
- err = fmt.Errorf("Error validating transaction root. Received %x, got %x", block.TxSha, txSha)
+ err = fmt.Errorf("validating transaction root. received=%x got=%x", block.TxSha, txSha)
return
}
receiptSha := DeriveSha(receipts)
if bytes.Compare(receiptSha, block.ReceiptSha) != 0 {
- err = fmt.Errorf("Error validating receipt root. Received %x, got %x", block.ReceiptSha, receiptSha)
+ err = fmt.Errorf("validating receipt root. received=%x got=%x", block.ReceiptSha, receiptSha)
return
}
// Block validation
if err = sm.ValidateBlock(block, parent); err != nil {
- statelogger.Errorln("Error validating block:", err)
+ statelogger.Errorln("validating block:", err)
return
}
if err = sm.AccumelateRewards(state, block, parent); err != nil {
- statelogger.Errorln("Error accumulating reward", err)
+ statelogger.Errorln("accumulating reward", err)
return
}
- block.receipts = receipts
- rbloom := CreateBloom(block)
+ block.receipts = receipts // although this isn't necessary it be in the future
+ rbloom := CreateBloom(receipts)
if bytes.Compare(rbloom, block.LogsBloom) != 0 {
- err = fmt.Errorf("unable to replicate block's bloom: %x", rbloom)
+ err = fmt.Errorf("unable to replicate block's bloom=%x", rbloom)
return
}
state.Update()
if !block.State().Cmp(state) {
- err = fmt.Errorf("Invalid merkle root.\nrec: %x\nis: %x", block.State().Root(), state.Root())
+ err = fmt.Errorf("invalid merkle root. received=%x got=%x", block.Root(), state.Root())
return
}
diff --git a/chain/bloom9.go b/chain/bloom9.go
index bf270127e..c610bd101 100644
--- a/chain/bloom9.go
+++ b/chain/bloom9.go
@@ -8,16 +8,16 @@ import (
"github.com/ethereum/go-ethereum/state"
)
-func CreateBloom(block *Block) []byte {
+func CreateBloom(receipts Receipts) []byte {
bin := new(big.Int)
- for _, receipt := range block.Receipts() {
- bin.Or(bin, LogsBloom(receipt.logs))
+ for _, receipt := range receipts {
+ bin.Or(bin, logsBloom(receipt.logs))
}
return ethutil.LeftPadBytes(bin.Bytes(), 64)
}
-func LogsBloom(logs state.Logs) *big.Int {
+func logsBloom(logs state.Logs) *big.Int {
bin := new(big.Int)
for _, log := range logs {
data := [][]byte{log.Address}
diff --git a/chain/receipt.go b/chain/receipt.go
index c2e6f53a5..fa53f1cdb 100644
--- a/chain/receipt.go
+++ b/chain/receipt.go
@@ -51,11 +51,7 @@ func (self *Receipt) Cmp(other *Receipt) bool {
}
func (self *Receipt) String() string {
- return fmt.Sprintf(`Receipt: %x
-cumulative gas: %v
-bloom: %x
-logs: %v
-rlp: %x`, self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs, self.RlpEncode())
+ return fmt.Sprintf("receipt{med=%x cgas=%v bloom=%x logs=%v}", self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs)
}
type Receipts []*Receipt