aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorBojie Wu <bojie@dexon.org>2018-11-01 17:53:06 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commitc024c9c424536244035382d2af524df6a7855c73 (patch)
tree5978c88ce87bf4e9aa2007d924cd2ad19120704e /core
parentce77665f5dc808eddb52e481f598a00d7138e107 (diff)
downloaddexon-c024c9c424536244035382d2af524df6a7855c73.tar.gz
dexon-c024c9c424536244035382d2af524df6a7855c73.tar.zst
dexon-c024c9c424536244035382d2af524df6a7855c73.zip
app: add lock to prevent concurrent map read write
Diffstat (limited to 'core')
-rw-r--r--core/blockchain.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 201b53d74..0b3672479 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]--