mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
core: verify state too when deduping existing blocks
This commit is contained in:
parent
c2d93ded35
commit
a26f669e34
1 changed files with 4 additions and 5 deletions
|
|
@ -792,15 +792,14 @@ func (bc *BlockChain) WriteBlockAndState(block *types.Block, receipts []*types.R
|
||||||
if ptd == nil {
|
if ptd == nil {
|
||||||
return NonStatTy, consensus.ErrUnknownAncestor
|
return NonStatTy, consensus.ErrUnknownAncestor
|
||||||
}
|
}
|
||||||
|
// If the block is already known, skip it
|
||||||
|
if bc.HasBlockAndState(block.Hash()) {
|
||||||
|
return SideStatTy, nil
|
||||||
|
}
|
||||||
// Make sure no inconsistent state is leaked during insertion
|
// Make sure no inconsistent state is leaked during insertion
|
||||||
bc.mu.Lock()
|
bc.mu.Lock()
|
||||||
defer bc.mu.Unlock()
|
defer bc.mu.Unlock()
|
||||||
|
|
||||||
if bc.HasBlock(block.Hash(), block.NumberU64()) {
|
|
||||||
log.Trace("Block existed", "hash", block.Hash())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
localTd := bc.GetTd(bc.currentBlock.Hash(), bc.currentBlock.NumberU64())
|
localTd := bc.GetTd(bc.currentBlock.Hash(), bc.currentBlock.NumberU64())
|
||||||
externTd := new(big.Int).Add(block.Difficulty(), ptd)
|
externTd := new(big.Int).Add(block.Difficulty(), ptd)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue