diff options
author | Bojie Wu <bojie@dexon.org> | 2018-10-09 13:28:45 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:52 +0800 |
commit | adb92b903b733e739e3c8ceff33cf0814f0dda31 (patch) | |
tree | fccf7dbce572bfe4444700ca24b291522e91dd6b /core | |
parent | a0b4489cb5f206acdbb130aca18ff2dcb6cfe0d1 (diff) | |
download | dexon-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.go | 6 |
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 |