diff options
author | Bojie Wu <bojie@dexon.org> | 2018-11-01 17:53:06 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2018-12-19 20:54:27 +0800 |
commit | d3390db38f6be5b7ea21f476eec6d617d9d44db1 (patch) | |
tree | a8d0b7c658cd322a3ef5f9aeff0aaf188174900b /core/blockchain.go | |
parent | ab6b87247328efbcf210e8287f56f6910e9a7162 (diff) | |
download | dexon-d3390db38f6be5b7ea21f476eec6d617d9d44db1.tar dexon-d3390db38f6be5b7ea21f476eec6d617d9d44db1.tar.gz dexon-d3390db38f6be5b7ea21f476eec6d617d9d44db1.tar.bz2 dexon-d3390db38f6be5b7ea21f476eec6d617d9d44db1.tar.lz dexon-d3390db38f6be5b7ea21f476eec6d617d9d44db1.tar.xz dexon-d3390db38f6be5b7ea21f476eec6d617d9d44db1.tar.zst dexon-d3390db38f6be5b7ea21f476eec6d617d9d44db1.zip |
app: add lock to prevent concurrent map read write
Diffstat (limited to 'core/blockchain.go')
-rw-r--r-- | core/blockchain.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index 1bbaf2bc9..3fd2e0692 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -290,6 +290,9 @@ func (bc *BlockChain) AddConfirmedBlock(block *coreTypes.Block) error { } func (bc *BlockChain) RemoveConfirmedBlock(hash coreCommon.Hash) { + bc.confirmedBlocksMu.Lock() + defer bc.confirmedBlocksMu.Unlock() + blockInfo := bc.confirmedBlocks[hash] for addr := range blockInfo.addresses { bc.addressCounter[addr]-- |