aboutsummaryrefslogtreecommitdiffstats
path: root/core/block_validator.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-04-06 19:58:03 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-04-06 22:34:19 +0800
commit158d603528d2ba36b633a8f22a2bff8329f69717 (patch)
tree7e95ceca2b57686e766182b6e6d14fe10704dcf8 /core/block_validator.go
parent702bef8493f0f3486072f1a7593fa582a1fb53d0 (diff)
downloaddexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar.gz
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar.bz2
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar.lz
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar.xz
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar.zst
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.zip
consensus, core: drop all the legacy custom core error types
Diffstat (limited to 'core/block_validator.go')
-rw-r--r--core/block_validator.go10
1 files changed, 5 insertions, 5 deletions
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.