aboutsummaryrefslogtreecommitdiffstats
path: root/dex/app.go
diff options
context:
space:
mode:
authorBJ4 <bojie@dexon.org>2018-11-03 12:03:27 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commit94eb66fad85f86a108df4a050cdaa6461b12c49f (patch)
treed1530cdbd4aacb5c3979c7b3eca673ecf1eb8414 /dex/app.go
parent5853525cb0de7bfa03029342e2427e2b929da9da (diff)
downloaddexon-94eb66fad85f86a108df4a050cdaa6461b12c49f.tar.gz
dexon-94eb66fad85f86a108df4a050cdaa6461b12c49f.tar.zst
dexon-94eb66fad85f86a108df4a050cdaa6461b12c49f.zip
app: add back mutex to prevent concurrent map read write
Diffstat (limited to 'dex/app.go')
-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
}