diff options
author | BJ4 <bojie@dexon.org> | 2018-11-03 12:03:27 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | 94eb66fad85f86a108df4a050cdaa6461b12c49f (patch) | |
tree | d1530cdbd4aacb5c3979c7b3eca673ecf1eb8414 /dex/app.go | |
parent | 5853525cb0de7bfa03029342e2427e2b929da9da (diff) | |
download | dexon-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.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 } |