mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
triedb/pathdb: double check pattern
This commit is contained in:
parent
127d1f42bb
commit
2f1722cd87
1 changed files with 10 additions and 0 deletions
|
|
@ -176,6 +176,11 @@ func (s *stateSet) accountList() []common.Hash {
|
||||||
s.listLock.Lock()
|
s.listLock.Lock()
|
||||||
defer s.listLock.Unlock()
|
defer s.listLock.Unlock()
|
||||||
|
|
||||||
|
//double check after acquiring the write lock
|
||||||
|
if list = s.accountListSorted; list != nil {
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
list = slices.SortedFunc(maps.Keys(s.accountData), common.Hash.Cmp)
|
list = slices.SortedFunc(maps.Keys(s.accountData), common.Hash.Cmp)
|
||||||
s.accountListSorted = list
|
s.accountListSorted = list
|
||||||
return list
|
return list
|
||||||
|
|
@ -206,6 +211,11 @@ func (s *stateSet) storageList(accountHash common.Hash) []common.Hash {
|
||||||
s.listLock.Lock()
|
s.listLock.Lock()
|
||||||
defer s.listLock.Unlock()
|
defer s.listLock.Unlock()
|
||||||
|
|
||||||
|
//double check after acquiring the write lock
|
||||||
|
if list := s.storageListSorted[accountHash]; list != nil {
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
list := slices.SortedFunc(maps.Keys(s.storageData[accountHash]), common.Hash.Cmp)
|
list := slices.SortedFunc(maps.Keys(s.storageData[accountHash]), common.Hash.Cmp)
|
||||||
s.storageListSorted[accountHash] = list
|
s.storageListSorted[accountHash] = list
|
||||||
return list
|
return list
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue