diff options
author | BJ4 <bojie@dexon.org> | 2018-11-03 12:03:27 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:52 +0800 |
commit | 6363124007ab898c76c38b9d7a55ce406976a690 (patch) | |
tree | a8e0fd80eed0046824942632bceb1b2b85e391ed /dex/app.go | |
parent | 7287da82d3f472b713b557fa4f55efd48876cef2 (diff) | |
download | dexon-6363124007ab898c76c38b9d7a55ce406976a690.tar dexon-6363124007ab898c76c38b9d7a55ce406976a690.tar.gz dexon-6363124007ab898c76c38b9d7a55ce406976a690.tar.bz2 dexon-6363124007ab898c76c38b9d7a55ce406976a690.tar.lz dexon-6363124007ab898c76c38b9d7a55ce406976a690.tar.xz dexon-6363124007ab898c76c38b9d7a55ce406976a690.tar.zst dexon-6363124007ab898c76c38b9d7a55ce406976a690.zip |
app: add back mutex to prevent concurrent map read write
Diffstat (limited to 'dex/app.go')
-rw-r--r-- | dex/app.go | 10 |
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 } |