aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorBJ4 <bojie@dexon.org>2018-11-03 12:03:27 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:17 +0800
commit5791a10ceb0f803f4d8c56909d663a9eecca6ffc (patch)
treeb900ca9c2b43175cf340d8aa476a0bbdc5e5a2bd /dex
parent3c14b7b9b2664476dd661cb332bd107418f42a09 (diff)
downloadgo-tangerine-5791a10ceb0f803f4d8c56909d663a9eecca6ffc.tar.gz
go-tangerine-5791a10ceb0f803f4d8c56909d663a9eecca6ffc.tar.zst
go-tangerine-5791a10ceb0f803f4d8c56909d663a9eecca6ffc.zip
app: add back mutex to prevent concurrent map read write
Diffstat (limited to 'dex')
-rw-r--r--dex/app.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/dex/app.go b/dex/app.go
index d28f5f490..643949aac 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -49,7 +49,9 @@ type DexconApp struct {
chainLocksInitMu sync.Mutex
chainLocks map[uint32]*sync.RWMutex
- chainLatestRoot map[uint32]*common.Hash
+
+ chainLatestRootMu sync.Mutex
+ chainLatestRoot map[uint32]*common.Hash
}
type notify struct {
@@ -467,10 +469,16 @@ func (d *DexconApp) validateNonce(txs types.Transactions) (map[common.Address]ui
}
func (d *DexconApp) getChainLatestRoot(chainID uint32) *common.Hash {
+ d.chainLatestRootMu.Lock()
+ defer d.chainLatestRootMu.Unlock()
+
return d.chainLatestRoot[chainID]
}
func (d *DexconApp) setChainLatestRoot(chainID uint32, root *common.Hash) {
+ d.chainLatestRootMu.Lock()
+ defer d.chainLatestRootMu.Unlock()
+
d.chainLatestRoot[chainID] = root
}