From 6363124007ab898c76c38b9d7a55ce406976a690 Mon Sep 17 00:00:00 2001 From: BJ4 Date: Sat, 3 Nov 2018 12:03:27 +0800 Subject: app: add back mutex to prevent concurrent map read write --- dex/app.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'dex/app.go') 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 } -- cgit v1.2.3