diff options
author | bojie <bojie@dexon.org> | 2019-01-17 20:17:18 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:56 +0800 |
commit | 4848d54d3a497990030831cb10ea69274ddbd2f2 (patch) | |
tree | e85cc3b1b1571952211941245da1f7079f396449 /core/blockchain.go | |
parent | 20d2c46820b895632f7abda71e57164264582b26 (diff) | |
download | dexon-4848d54d3a497990030831cb10ea69274ddbd2f2.tar dexon-4848d54d3a497990030831cb10ea69274ddbd2f2.tar.gz dexon-4848d54d3a497990030831cb10ea69274ddbd2f2.tar.bz2 dexon-4848d54d3a497990030831cb10ea69274ddbd2f2.tar.lz dexon-4848d54d3a497990030831cb10ea69274ddbd2f2.tar.xz dexon-4848d54d3a497990030831cb10ea69274ddbd2f2.tar.zst dexon-4848d54d3a497990030831cb10ea69274ddbd2f2.zip |
blockchain: add mutex lock to prevent fork (#159)
Diffstat (limited to 'core/blockchain.go')
-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 e6d7cdc76..99f99b64d 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1818,7 +1818,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() @@ -1941,6 +1940,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() |