core/state/snapshot: reduce disk layer depth during generation

This commit is contained in:
Péter Szilágyi
2020-08-24 13:22:36 +03:00
parent 0f4e7c9b0d
commit 3ee91b9f2e
3 changed files with 18 additions and 9 deletions

View File

@ -263,6 +263,13 @@ func (t *Tree) Cap(root common.Hash, layers int) error {
if !ok {
return fmt.Errorf("snapshot [%#x] is disk layer", root)
}
// If the generator is still running, use a more aggressive cap
diff.origin.lock.RLock()
if diff.origin.genMarker != nil && layers > 8 {
layers = 8
}
diff.origin.lock.RUnlock()
// Run the internal capping and discard all stale layers
t.lock.Lock()
defer t.lock.Unlock()