mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
core/state: split the lock into two
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
7c5fc085b0
commit
a1cdc4f19f
1 changed files with 8 additions and 7 deletions
|
|
@ -1122,7 +1122,8 @@ func (s *StateDB) commit(deleteEmptyObjects bool, noStorageWiping bool) (*stateU
|
||||||
storageTrieNodesUpdated atomic.Int32
|
storageTrieNodesUpdated atomic.Int32
|
||||||
storageTrieNodesDeleted atomic.Int32
|
storageTrieNodesDeleted atomic.Int32
|
||||||
|
|
||||||
lock sync.Mutex // protect two maps below
|
nodesLock sync.Mutex // protect the nodes map
|
||||||
|
updatesLock sync.Mutex // protect the updates map
|
||||||
nodes = trienode.NewMergedNodeSet() // aggregated trie nodes
|
nodes = trienode.NewMergedNodeSet() // aggregated trie nodes
|
||||||
updates = make(map[common.Hash]*accountUpdate, len(s.mutations)) // aggregated account updates
|
updates = make(map[common.Hash]*accountUpdate, len(s.mutations)) // aggregated account updates
|
||||||
|
|
||||||
|
|
@ -1149,8 +1150,8 @@ func (s *StateDB) commit(deleteEmptyObjects bool, noStorageWiping bool) (*stateU
|
||||||
storageTrieNodesDeleted.Add(int32(deletes))
|
storageTrieNodesDeleted.Add(int32(deletes))
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.Lock()
|
nodesLock.Lock()
|
||||||
defer lock.Unlock()
|
defer nodesLock.Unlock()
|
||||||
return nodes.Merge(set)
|
return nodes.Merge(set)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -1221,10 +1222,10 @@ func (s *StateDB) commit(deleteEmptyObjects bool, noStorageWiping bool) (*stateU
|
||||||
if err := merge(set); err != nil {
|
if err := merge(set); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
lock.Lock()
|
updatesLock.Lock()
|
||||||
updates[obj.addrHash] = update
|
updates[obj.addrHash] = update
|
||||||
s.StorageCommits = time.Since(start) // overwrite with the longest storage commit runtime
|
s.StorageCommits = time.Since(start) // overwrite with the longest storage commit runtime
|
||||||
lock.Unlock()
|
updatesLock.Unlock()
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue