diff options
author | Bojie Wu <bojie@dexon.org> | 2018-11-01 17:53:06 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:52 +0800 |
commit | 9ebd1473b3b91d929a5bc503cae43fa6ac36ab79 (patch) | |
tree | 8cb0f5064abb35dae4ae1e439d5885eb6e29a300 /core/blockchain.go | |
parent | 515b06fa46fa56c5fca1c3f44826cf2fd090409b (diff) | |
download | dexon-9ebd1473b3b91d929a5bc503cae43fa6ac36ab79.tar dexon-9ebd1473b3b91d929a5bc503cae43fa6ac36ab79.tar.gz dexon-9ebd1473b3b91d929a5bc503cae43fa6ac36ab79.tar.bz2 dexon-9ebd1473b3b91d929a5bc503cae43fa6ac36ab79.tar.lz dexon-9ebd1473b3b91d929a5bc503cae43fa6ac36ab79.tar.xz dexon-9ebd1473b3b91d929a5bc503cae43fa6ac36ab79.tar.zst dexon-9ebd1473b3b91d929a5bc503cae43fa6ac36ab79.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 264617857..1a60805a1 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]-- |