From 4f9789b28d570ccd234640f1c13c08cb9f16f4ee Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 31 Jul 2017 04:59:07 -0500 Subject: [PATCH] core: avoid write existing block again (#14849) --- core/blockchain.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/blockchain.go b/core/blockchain.go index bb1c14f437..3fb8be15f4 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -827,6 +827,11 @@ func (bc *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err er bc.mu.Lock() 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()) externTd := new(big.Int).Add(block.Difficulty(), ptd)