|
|
@ -54,9 +54,11 @@ type generatorStats struct { |
|
|
|
|
|
|
|
|
|
|
|
// Log creates an contextual log with the given message and the context pulled
|
|
|
|
// Log creates an contextual log with the given message and the context pulled
|
|
|
|
// from the internally maintained statistics.
|
|
|
|
// from the internally maintained statistics.
|
|
|
|
func (gs *generatorStats) Log(msg string, marker []byte) { |
|
|
|
func (gs *generatorStats) Log(msg string, root common.Hash, marker []byte) { |
|
|
|
var ctx []interface{} |
|
|
|
var ctx []interface{} |
|
|
|
|
|
|
|
if root != (common.Hash{}) { |
|
|
|
|
|
|
|
ctx = append(ctx, []interface{}{"root", root}...) |
|
|
|
|
|
|
|
} |
|
|
|
// Figure out whether we're after or within an account
|
|
|
|
// Figure out whether we're after or within an account
|
|
|
|
switch len(marker) { |
|
|
|
switch len(marker) { |
|
|
|
case common.HashLength: |
|
|
|
case common.HashLength: |
|
|
@ -120,7 +122,7 @@ func generateSnapshot(diskdb ethdb.KeyValueStore, triedb *trie.Database, cache i |
|
|
|
func (dl *diskLayer) generate(stats *generatorStats) { |
|
|
|
func (dl *diskLayer) generate(stats *generatorStats) { |
|
|
|
// If a database wipe is in operation, wait until it's done
|
|
|
|
// If a database wipe is in operation, wait until it's done
|
|
|
|
if stats.wiping != nil { |
|
|
|
if stats.wiping != nil { |
|
|
|
stats.Log("Wiper running, state snapshotting paused", dl.genMarker) |
|
|
|
stats.Log("Wiper running, state snapshotting paused", common.Hash{}, dl.genMarker) |
|
|
|
select { |
|
|
|
select { |
|
|
|
// If wiper is done, resume normal mode of operation
|
|
|
|
// If wiper is done, resume normal mode of operation
|
|
|
|
case <-stats.wiping: |
|
|
|
case <-stats.wiping: |
|
|
@ -137,13 +139,13 @@ func (dl *diskLayer) generate(stats *generatorStats) { |
|
|
|
accTrie, err := trie.NewSecure(dl.root, dl.triedb) |
|
|
|
accTrie, err := trie.NewSecure(dl.root, dl.triedb) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
// The account trie is missing (GC), surf the chain until one becomes available
|
|
|
|
// The account trie is missing (GC), surf the chain until one becomes available
|
|
|
|
stats.Log("Trie missing, state snapshotting paused", dl.genMarker) |
|
|
|
stats.Log("Trie missing, state snapshotting paused", dl.root, dl.genMarker) |
|
|
|
|
|
|
|
|
|
|
|
abort := <-dl.genAbort |
|
|
|
abort := <-dl.genAbort |
|
|
|
abort <- stats |
|
|
|
abort <- stats |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
stats.Log("Resuming state snapshot generation", dl.genMarker) |
|
|
|
stats.Log("Resuming state snapshot generation", dl.root, dl.genMarker) |
|
|
|
|
|
|
|
|
|
|
|
var accMarker []byte |
|
|
|
var accMarker []byte |
|
|
|
if len(dl.genMarker) > 0 { // []byte{} is the start, use nil for that
|
|
|
|
if len(dl.genMarker) > 0 { // []byte{} is the start, use nil for that
|
|
|
@ -192,7 +194,7 @@ func (dl *diskLayer) generate(stats *generatorStats) { |
|
|
|
dl.lock.Unlock() |
|
|
|
dl.lock.Unlock() |
|
|
|
} |
|
|
|
} |
|
|
|
if abort != nil { |
|
|
|
if abort != nil { |
|
|
|
stats.Log("Aborting state snapshot generation", accountHash[:]) |
|
|
|
stats.Log("Aborting state snapshot generation", dl.root, accountHash[:]) |
|
|
|
abort <- stats |
|
|
|
abort <- stats |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -230,7 +232,7 @@ func (dl *diskLayer) generate(stats *generatorStats) { |
|
|
|
dl.lock.Unlock() |
|
|
|
dl.lock.Unlock() |
|
|
|
} |
|
|
|
} |
|
|
|
if abort != nil { |
|
|
|
if abort != nil { |
|
|
|
stats.Log("Aborting state snapshot generation", append(accountHash[:], storeIt.Key...)) |
|
|
|
stats.Log("Aborting state snapshot generation", dl.root, append(accountHash[:], storeIt.Key...)) |
|
|
|
abort <- stats |
|
|
|
abort <- stats |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -238,7 +240,7 @@ func (dl *diskLayer) generate(stats *generatorStats) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if time.Since(logged) > 8*time.Second { |
|
|
|
if time.Since(logged) > 8*time.Second { |
|
|
|
stats.Log("Generating state snapshot", accIt.Key) |
|
|
|
stats.Log("Generating state snapshot", dl.root, accIt.Key) |
|
|
|
logged = time.Now() |
|
|
|
logged = time.Now() |
|
|
|
} |
|
|
|
} |
|
|
|
// Some account processed, unmark the marker
|
|
|
|
// Some account processed, unmark the marker
|
|
|
|