aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorBojie Wu <bojie@dexon.org>2018-10-09 13:28:45 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:52 +0800
commitadb92b903b733e739e3c8ceff33cf0814f0dda31 (patch)
treefccf7dbce572bfe4444700ca24b291522e91dd6b /core
parenta0b4489cb5f206acdbb130aca18ff2dcb6cfe0d1 (diff)
downloaddexon-adb92b903b733e739e3c8ceff33cf0814f0dda31.tar
dexon-adb92b903b733e739e3c8ceff33cf0814f0dda31.tar.gz
dexon-adb92b903b733e739e3c8ceff33cf0814f0dda31.tar.bz2
dexon-adb92b903b733e739e3c8ceff33cf0814f0dda31.tar.lz
dexon-adb92b903b733e739e3c8ceff33cf0814f0dda31.tar.xz
dexon-adb92b903b733e739e3c8ceff33cf0814f0dda31.tar.zst
dexon-adb92b903b733e739e3c8ceff33cf0814f0dda31.zip
app: fix concurrent read write issue with map
Diffstat (limited to 'core')
-rw-r--r--core/blockchain.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index b38aa35dd..80d4b2f08 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -260,10 +260,16 @@ func (bc *BlockChain) RemoveConfirmedBlock(hash coreCommon.Hash) {
}
func (bc *BlockChain) GetConfirmedBlockByHash(hash coreCommon.Hash) *coreTypes.Block {
+ bc.confirmedBlockMu.Lock()
+ defer bc.confirmedBlockMu.Unlock()
+
return bc.confirmedBlocks[hash]
}
func (bc *BlockChain) GetConfirmedTxsByAddress(chainID uint32, address common.Address) (types.Transactions, error) {
+ bc.confirmedBlockMu.Lock()
+ defer bc.confirmedBlockMu.Unlock()
+
var addressTxs types.Transactions
for _, block := range bc.chainConfirmedBlocks[chainID] {
var transactions types.Transactions