diff options
author | bojie <bojie@dexon.org> | 2019-01-17 20:17:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-17 20:17:18 +0800 |
commit | c747a02ee7a0be39fa6e23fc5d9778f5cfc58c50 (patch) | |
tree | c416db800671917606329f7ae2912613ed6eca74 | |
parent | 78dfa1fcac7125048a20f35060497b7eb03fb0b7 (diff) | |
download | dexon-c747a02ee7a0be39fa6e23fc5d9778f5cfc58c50.tar dexon-c747a02ee7a0be39fa6e23fc5d9778f5cfc58c50.tar.gz dexon-c747a02ee7a0be39fa6e23fc5d9778f5cfc58c50.tar.bz2 dexon-c747a02ee7a0be39fa6e23fc5d9778f5cfc58c50.tar.lz dexon-c747a02ee7a0be39fa6e23fc5d9778f5cfc58c50.tar.xz dexon-c747a02ee7a0be39fa6e23fc5d9778f5cfc58c50.tar.zst dexon-c747a02ee7a0be39fa6e23fc5d9778f5cfc58c50.zip |
blockchain: add mutex lock to prevent fork (#159)
-rw-r--r-- | core/blockchain.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index 99d79519e..b076df48f 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1812,7 +1812,6 @@ func (bc *BlockChain) ProcessBlock(block *types.Block, witness *coreTypes.Witnes func (bc *BlockChain) processBlock( block *types.Block, witness *coreTypes.Witness) (*common.Hash, []interface{}, []*types.Log, error) { - // Pre-checks passed, start the full block imports bc.wg.Add(1) defer bc.wg.Done() @@ -1935,6 +1934,12 @@ func (bc *BlockChain) processBlock( } func (bc *BlockChain) ProcessEmptyBlock(block *types.Block) (*common.Hash, error) { + bc.wg.Add(1) + defer bc.wg.Done() + + bc.chainmu.Lock() + defer bc.chainmu.Unlock() + bstart := time.Now() var stats = insertStats{startTime: mclock.Now()} var header = block.Header() |