aboutsummaryrefslogtreecommitdiffstats
path: root/chain/block_manager.go
diff options
context:
space:
mode:
Diffstat (limited to 'chain/block_manager.go')
-rw-r--r--chain/block_manager.go28
1 files changed, 15 insertions, 13 deletions
diff --git a/chain/block_manager.go b/chain/block_manager.go
index b7c805129..efe9e0862 100644
--- a/chain/block_manager.go
+++ b/chain/block_manager.go
@@ -159,7 +159,8 @@ done:
txGas.Sub(txGas, st.gas)
cumulative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas))
- receipt := &Receipt{ethutil.CopyBytes(state.Root().([]byte)), cumulative, LogsBloom(state.Logs()).Bytes(), 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})
@@ -213,40 +214,41 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
if err != nil {
return
}
- block.SetReceipts(receipts)
txSha := DeriveSha(block.transactions)
if bytes.Compare(txSha, block.TxSha) != 0 {
- err = fmt.Errorf("Error validating transaction sha. 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 sha. 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
}
- if bytes.Compare(CreateBloom(block), block.LogsBloom) != 0 {
- err = errors.New("Unable to replicate block's bloom")
+ 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)
return
}
state.Update()
if !block.State().Cmp(state) {
- err = fmt.Errorf("Invalid merkle root.\nrec: %x\nis: %x", block.State().Trie.Root, state.Trie.Root)
+ err = fmt.Errorf("invalid merkle root. received=%x got=%x", block.Root(), state.Root())
return
}
@@ -255,13 +257,13 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
// Sync the current block's state to the database and cancelling out the deferred Undo
state.Sync()
- // TODO at this point we should also insert LOGS in to a database
-
- sm.transState = state.Copy()
-
messages := state.Manifest().Messages
state.Manifest().Reset()
+ chainlogger.Infof("Processed block #%d (%x...)\n", block.Number, block.Hash()[0:4])
+
+ sm.transState = state.Copy()
+
sm.eth.TxPool().RemoveSet(block.Transactions())
return td, messages, nil