From c024c9c424536244035382d2af524df6a7855c73 Mon Sep 17 00:00:00 2001 From: Bojie Wu Date: Thu, 1 Nov 2018 17:53:06 +0800 Subject: app: add lock to prevent concurrent map read write --- core/blockchain.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'core') 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]-- -- cgit