diff options
author | Mark <markya0616@gmail.com> | 2017-07-31 17:59:07 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-07-31 17:59:07 +0800 |
commit | 4f9789b28d570ccd234640f1c13c08cb9f16f4ee (patch) | |
tree | 40b753aaaca5877575bd631acba88818e6997a24 | |
parent | ee748d14512cbaa08d9734e43a52fb771995ce31 (diff) | |
download | dexon-4f9789b28d570ccd234640f1c13c08cb9f16f4ee.tar.gz dexon-4f9789b28d570ccd234640f1c13c08cb9f16f4ee.tar.zst dexon-4f9789b28d570ccd234640f1c13c08cb9f16f4ee.zip |
core: avoid write existing block again (#14849)
-rw-r--r-- | core/blockchain.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index bb1c14f43..3fb8be15f 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) |