mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
triedb/pathdb: double check the list availability before regeneration (#33622)
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
This commit is contained in:
parent
500931bc82
commit
d0af257aa2
1 changed files with 8 additions and 6 deletions
|
|
@ -170,12 +170,13 @@ func (s *stateSet) accountList() []common.Hash {
|
|||
if list != nil {
|
||||
return list
|
||||
}
|
||||
// No old sorted account list exists, generate a new one. It's possible that
|
||||
// multiple threads waiting for the write lock may regenerate the list
|
||||
// multiple times, which is acceptable.
|
||||
s.listLock.Lock()
|
||||
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)
|
||||
s.accountListSorted = list
|
||||
return list
|
||||
|
|
@ -200,12 +201,13 @@ func (s *stateSet) storageList(accountHash common.Hash) []common.Hash {
|
|||
}
|
||||
s.listLock.RUnlock()
|
||||
|
||||
// No old sorted account list exists, generate a new one. It's possible that
|
||||
// multiple threads waiting for the write lock may regenerate the list
|
||||
// multiple times, which is acceptable.
|
||||
s.listLock.Lock()
|
||||
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)
|
||||
s.storageListSorted[accountHash] = list
|
||||
return list
|
||||
|
|
|
|||
Loading…
Reference in a new issue