diff options
Diffstat (limited to 'core/blockchain.go')
-rw-r--r-- | core/blockchain.go | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index bbcff3b92..9ace6d79a 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -878,7 +878,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) { if BadHashes[block.Hash()] { err := BadHashError(block.Hash()) - reportBlock(block, err) + self.reportBlock(block, nil, err) return i, err } // Stage 1 validation of the block using the chain's validator @@ -910,7 +910,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) { continue } - reportBlock(block, err) + self.reportBlock(block, nil, err) return i, err } @@ -924,19 +924,19 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) { err = self.stateCache.Reset(chain[i-1].Root()) } if err != nil { - reportBlock(block, err) + self.reportBlock(block, nil, err) return i, err } // Process block using the parent state as reference point. receipts, logs, usedGas, err := self.processor.Process(block, self.stateCache, vm.Config{}) if err != nil { - reportBlock(block, err) + self.reportBlock(block, receipts, err) return i, err } // Validate the state using the default validator err = self.Validator().ValidateState(block, self.GetBlock(block.ParentHash(), block.NumberU64()-1), self.stateCache, receipts, usedGas) if err != nil { - reportBlock(block, err) + self.reportBlock(block, receipts, err) return i, err } // Write state changes to database @@ -1207,10 +1207,23 @@ func (self *BlockChain) update() { } // reportBlock logs a bad block error. -func reportBlock(block *types.Block, err error) { +func (bc *BlockChain) reportBlock(block *types.Block, receipts types.Receipts, err error) { if glog.V(logger.Error) { - glog.Errorf("Bad block #%v (%s)\n", block.Number(), block.Hash().Hex()) - glog.Errorf(" %v", err) + var receiptString string + for _, receipt := range receipts { + receiptString += fmt.Sprintf("\t%v\n", receipt) + } + glog.Errorf(` +########## BAD BLOCK ######### +Chain config: %v + +Number: %v +Hash: 0x%x +%v + +Error: %v +############################## +`, bc.config, block.Number(), block.Hash(), receiptString, err) } } |