mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
Merge pull request #901 from gzliudan/fix_validator
core, eth/downloader: fix validation and downloader printout flaw
This commit is contained in:
commit
7b3e57eacd
2 changed files with 7 additions and 6 deletions
|
|
@ -59,12 +59,6 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
|
|||
if v.bc.HasBlockAndFullState(block.Hash(), block.NumberU64()) {
|
||||
return ErrKnownBlock
|
||||
}
|
||||
if !v.bc.HasBlockAndFullState(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 {
|
||||
|
|
@ -76,6 +70,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.HasBlockAndFullState(block.ParentHash(), block.NumberU64()-1) {
|
||||
if !v.bc.HasBlock(block.ParentHash(), block.NumberU64()-1) {
|
||||
return consensus.ErrUnknownAncestor
|
||||
}
|
||||
return consensus.ErrPrunedAncestor
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -826,6 +826,7 @@ func (d *Downloader) findAncestor(p *peerConnection, remoteHeader *types.Header)
|
|||
return 0, errBadPeer
|
||||
}
|
||||
start = check
|
||||
hash = h
|
||||
|
||||
case <-timeout:
|
||||
p.log.Debug("Waiting for search header timed out", "elapsed", ttl)
|
||||
|
|
|
|||
Loading…
Reference in a new issue