core/state/snapshot : use mark stale in different layer

This commit is contained in:
ucwong 2024-09-07 04:18:22 +08:00
parent d71831255d
commit 921fa574a6
2 changed files with 10 additions and 6 deletions

View file

@ -541,3 +541,11 @@ func (dl *diffLayer) StorageList(accountHash common.Hash) ([]common.Hash, bool)
dl.memory += uint64(len(dl.storageList)*common.HashLength + common.HashLength)
return storageList, destructed
}
// markStale sets the stale flag as true.
func (dl *diffLayer) markStale() {
dl.lock.Lock()
defer dl.lock.Unlock()
dl.stale.Store(true)
}

View file

@ -266,9 +266,7 @@ func (t *Tree) Disable() {
case *diffLayer:
// If the layer is a simple diff, simply mark as stale
layer.lock.Lock()
layer.stale.Store(true)
layer.lock.Unlock()
layer.markStale()
default:
panic(fmt.Sprintf("unknown layer type: %T", layer))
@ -725,9 +723,7 @@ func (t *Tree) Rebuild(root common.Hash) {
case *diffLayer:
// If the layer is a simple diff, simply mark as stale
layer.lock.Lock()
layer.stale.Store(true)
layer.lock.Unlock()
layer.markStale()
default:
panic(fmt.Sprintf("unknown layer type: %T", layer))