aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBojie Wu <bojie@dexon.org>2018-11-01 17:53:06 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 13:49:55 +0800
commit487becec042f78bb20d43cf503b1e77ea9408a5a (patch)
treeb445265fb8e87826f9296f4be48618efc045047f
parente8a3c11a252b3520f0a82589e6067da5bd23a8e3 (diff)
downloaddexon-487becec042f78bb20d43cf503b1e77ea9408a5a.tar
dexon-487becec042f78bb20d43cf503b1e77ea9408a5a.tar.gz
dexon-487becec042f78bb20d43cf503b1e77ea9408a5a.tar.bz2
dexon-487becec042f78bb20d43cf503b1e77ea9408a5a.tar.lz
dexon-487becec042f78bb20d43cf503b1e77ea9408a5a.tar.xz
dexon-487becec042f78bb20d43cf503b1e77ea9408a5a.tar.zst
dexon-487becec042f78bb20d43cf503b1e77ea9408a5a.zip
app: add lock to prevent concurrent map read write
-rw-r--r--core/blockchain.go3
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]--