diff options
author | Bojie Wu <bojie@dexon.org> | 2018-10-09 13:28:45 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:17 +0800 |
commit | f5e29152b2b8113f3c205c197952d826ccc729ae (patch) | |
tree | ab9d1725861e1612e9c87fe1bc3068ff34ab89b9 | |
parent | 1d3949f4a7d0e03badcfb682dbba99608b41e1c9 (diff) | |
download | go-tangerine-f5e29152b2b8113f3c205c197952d826ccc729ae.tar go-tangerine-f5e29152b2b8113f3c205c197952d826ccc729ae.tar.gz go-tangerine-f5e29152b2b8113f3c205c197952d826ccc729ae.tar.bz2 go-tangerine-f5e29152b2b8113f3c205c197952d826ccc729ae.tar.lz go-tangerine-f5e29152b2b8113f3c205c197952d826ccc729ae.tar.xz go-tangerine-f5e29152b2b8113f3c205c197952d826ccc729ae.tar.zst go-tangerine-f5e29152b2b8113f3c205c197952d826ccc729ae.zip |
app: fix concurrent read write issue with map
-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 |