aboutsummaryrefslogtreecommitdiffstats
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 13:49:55 +0800
commit4440a1e67f317275c3b68201a5561bdbfe59165f (patch)
tree8d5cd351589fecd8f1f6d41d50d9be70a1003497
parentaa280a17889fe70107466520ffe01ec78473a836 (diff)
downloaddexon-4440a1e67f317275c3b68201a5561bdbfe59165f.tar
dexon-4440a1e67f317275c3b68201a5561bdbfe59165f.tar.gz
dexon-4440a1e67f317275c3b68201a5561bdbfe59165f.tar.bz2
dexon-4440a1e67f317275c3b68201a5561bdbfe59165f.tar.lz
dexon-4440a1e67f317275c3b68201a5561bdbfe59165f.tar.xz
dexon-4440a1e67f317275c3b68201a5561bdbfe59165f.tar.zst
dexon-4440a1e67f317275c3b68201a5561bdbfe59165f.zip
app: fix concurrent read write issue with map
-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