good morning!!!!

Skip to content
Snippets Groups Projects
Commit 4f9789b2 authored by Mark's avatar Mark Committed by Felix Lange
Browse files

core: avoid write existing block again (#14849)

parent ee748d14
Branches
Tags
No related merge requests found
...@@ -827,6 +827,11 @@ func (bc *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err er ...@@ -827,6 +827,11 @@ func (bc *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err er
bc.mu.Lock() bc.mu.Lock()
defer bc.mu.Unlock() defer bc.mu.Unlock()
if bc.HasBlock(block.Hash()) {
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment