From 158d603528d2ba36b633a8f22a2bff8329f69717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 6 Apr 2017 14:58:03 +0300 Subject: consensus, core: drop all the legacy custom core error types --- core/block_validator.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'core/block_validator.go') diff --git a/core/block_validator.go b/core/block_validator.go index 00457dd7a..4f85df007 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -54,15 +54,15 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { // Check whether the block's known, and if not, that it's linkable if v.bc.HasBlock(block.Hash()) { if _, err := state.New(block.Root(), v.bc.chainDb); err == nil { - return &KnownBlockError{block.Number(), block.Hash()} + return ErrKnownBlock } } parent := v.bc.GetBlock(block.ParentHash(), block.NumberU64()-1) if parent == nil { - return ParentError(block.ParentHash()) + return consensus.ErrUnknownAncestor } if _, err := state.New(parent.Root(), v.bc.chainDb); err != nil { - return ParentError(block.ParentHash()) + return consensus.ErrUnknownAncestor } // Header validity is known at this point, check the uncles and transactions header := block.Header() @@ -82,10 +82,10 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { // transition, such as amount of used gas, the receipt roots and the state root // itself. ValidateState returns a database batch if the validation was a success // otherwise nil and an error is returned. -func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *state.StateDB, receipts types.Receipts, usedGas *big.Int) (err error) { +func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *state.StateDB, receipts types.Receipts, usedGas *big.Int) error { header := block.Header() if block.GasUsed().Cmp(usedGas) != 0 { - return ValidationError(fmt.Sprintf("invalid gas used (remote: %v local: %v)", block.GasUsed(), usedGas)) + return fmt.Errorf("invalid gas used (remote: %v local: %v)", block.GasUsed(), usedGas) } // Validate the received block's bloom with the one derived from the generated receipts. // For valid blocks this should always validate to true. -- cgit v1.2.3