mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
revert unnecessary change
This commit is contained in:
parent
e2c50738f8
commit
17ddd470fb
2 changed files with 12 additions and 9 deletions
|
|
@ -525,20 +525,19 @@ func (dl *diffLayer) StorageList(accountHash common.Hash) ([]common.Hash, bool)
|
|||
dl.lock.RUnlock()
|
||||
return list, destructed // the cached list can't be nil
|
||||
}
|
||||
storageMap := dl.storageData[accountHash]
|
||||
dl.lock.RUnlock()
|
||||
|
||||
// No old sorted account list exists, generate a new one
|
||||
dl.lock.Lock()
|
||||
defer dl.lock.Unlock()
|
||||
|
||||
storageMap := dl.storageData[accountHash]
|
||||
storageList := make([]common.Hash, 0, len(storageMap))
|
||||
for k := range storageMap {
|
||||
storageList = append(storageList, k)
|
||||
}
|
||||
slices.SortFunc(storageList, common.Hash.Cmp)
|
||||
|
||||
// No old sorted account list exists, generate a new one
|
||||
dl.lock.Lock()
|
||||
dl.storageList[accountHash] = storageList
|
||||
dl.memory += uint64(len(dl.storageList)*common.HashLength + common.HashLength)
|
||||
dl.lock.Unlock()
|
||||
|
||||
return storageList, destructed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -818,12 +818,10 @@ func (t *Tree) Verify(root common.Hash) error {
|
|||
// The lock of snapTree is assumed to be held already.
|
||||
func (t *Tree) disklayer() *diskLayer {
|
||||
var snap snapshot
|
||||
t.lock.RLock()
|
||||
for _, s := range t.layers {
|
||||
snap = s
|
||||
break
|
||||
}
|
||||
t.lock.RUnlock()
|
||||
if snap == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -852,6 +850,9 @@ func (t *Tree) diskRoot() common.Hash {
|
|||
// generating is an internal helper function which reports whether the snapshot
|
||||
// is still under the construction.
|
||||
func (t *Tree) generating() (bool, error) {
|
||||
t.lock.Lock()
|
||||
defer t.lock.Unlock()
|
||||
|
||||
layer := t.disklayer()
|
||||
if layer == nil {
|
||||
return false, errors.New("disk layer is missing")
|
||||
|
|
@ -861,8 +862,11 @@ func (t *Tree) generating() (bool, error) {
|
|||
return layer.genMarker != nil, nil
|
||||
}
|
||||
|
||||
// DiskRoot is a external helper function to return the disk layer root.
|
||||
// DiskRoot is an external helper function to return the disk layer root.
|
||||
func (t *Tree) DiskRoot() common.Hash {
|
||||
t.lock.Lock()
|
||||
defer t.lock.Unlock()
|
||||
|
||||
return t.diskRoot()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue