diff options
author | Martin Holst Swende <martin@swende.se> | 2018-11-07 20:47:11 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-11-07 20:47:11 +0800 |
commit | eea3ae42a3d9bcbd33474c0e482754c5196a469f (patch) | |
tree | accac7a5839c0f705482bbfe4ac08c95bee8b795 /core | |
parent | dc6648bb58fb37f7b5d9fd8e7ffbeb4cf45492fd (diff) | |
download | go-tangerine-eea3ae42a3d9bcbd33474c0e482754c5196a469f.tar go-tangerine-eea3ae42a3d9bcbd33474c0e482754c5196a469f.tar.gz go-tangerine-eea3ae42a3d9bcbd33474c0e482754c5196a469f.tar.bz2 go-tangerine-eea3ae42a3d9bcbd33474c0e482754c5196a469f.tar.lz go-tangerine-eea3ae42a3d9bcbd33474c0e482754c5196a469f.tar.xz go-tangerine-eea3ae42a3d9bcbd33474c0e482754c5196a469f.tar.zst go-tangerine-eea3ae42a3d9bcbd33474c0e482754c5196a469f.zip |
core, eth/downloader: fix validation flaw, fix downloader printout flaw (#17974)
Diffstat (limited to 'core')
-rw-r--r-- | core/block_validator.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/core/block_validator.go b/core/block_validator.go index 1329f6242..3b9496fec 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -53,12 +53,6 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { if v.bc.HasBlockAndState(block.Hash(), block.NumberU64()) { return ErrKnownBlock } - if !v.bc.HasBlockAndState(block.ParentHash(), block.NumberU64()-1) { - if !v.bc.HasBlock(block.ParentHash(), block.NumberU64()-1) { - return consensus.ErrUnknownAncestor - } - return consensus.ErrPrunedAncestor - } // Header validity is known at this point, check the uncles and transactions header := block.Header() if err := v.engine.VerifyUncles(v.bc, block); err != nil { @@ -70,6 +64,12 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { if hash := types.DeriveSha(block.Transactions()); hash != header.TxHash { return fmt.Errorf("transaction root hash mismatch: have %x, want %x", hash, header.TxHash) } + if !v.bc.HasBlockAndState(block.ParentHash(), block.NumberU64()-1) { + if !v.bc.HasBlock(block.ParentHash(), block.NumberU64()-1) { + return consensus.ErrUnknownAncestor + } + return consensus.ErrPrunedAncestor + } return nil } |