Skip to content

Commit 6694831

Browse files
tylerchambersfjl
andauthored
core/state/snapshot: clarify comment about snapshot repair (#23305)
Co-authored-by: Tyler Chambers <[email protected]> Co-authored-by: Felix Lange <[email protected]>
1 parent 57d9e0a commit 6694831

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

core/state/snapshot/snapshot.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,17 @@ type Tree struct {
169169
// store (with a number of memory layers from a journal), ensuring that the head
170170
// of the snapshot matches the expected one.
171171
//
172-
// If the snapshot is missing or the disk layer is broken, the entire is deleted
173-
// and will be reconstructed from scratch based on the tries in the key-value
174-
// store, on a background thread. If the memory layers from the journal is not
175-
// continuous with disk layer or the journal is missing, all diffs will be discarded
176-
// iff it's in "recovery" mode, otherwise rebuild is mandatory.
172+
// If the snapshot is missing or the disk layer is broken, the snapshot will be
173+
// reconstructed using both the existing data and the state trie.
174+
// The repair happens on a background thread.
175+
//
176+
// If the memory layers in the journal do not match the disk layer (e.g. there is
177+
// a gap) or the journal is missing, there are two repair cases:
178+
//
179+
// - if the 'recovery' parameter is true, all memory diff-layers will be discarded.
180+
// This case happens when the snapshot is 'ahead' of the state trie.
181+
// - otherwise, the entire snapshot is considered invalid and will be recreated on
182+
// a background thread.
177183
func New(diskdb ethdb.KeyValueStore, triedb *trie.Database, cache int, root common.Hash, async bool, rebuild bool, recovery bool) (*Tree, error) {
178184
// Create a new, empty snapshot tree
179185
snap := &Tree{

0 commit comments

Comments
 (0)