core/state/snapshot: add a missing lock (#30001)

* upgrade lock usage

* revert unnecessary change
This commit is contained in:
maskpp 2024-06-17 15:42:39 +08:00 committed by GitHub
parent fd5078c779
commit 34b46a2f75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -829,6 +829,8 @@ func (t *Tree) disklayer() *diskLayer {
case *diskLayer:
return layer
case *diffLayer:
layer.lock.RLock()
defer layer.lock.RUnlock()
return layer.origin
default:
panic(fmt.Sprintf("%T: undefined layer", snap))
@ -860,7 +862,7 @@ 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()