core, eth: abort snapshot generation on snap sync and resume later
This commit is contained in:
@ -24,6 +24,26 @@ import (
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
)
|
||||
|
||||
// ReadSnapshotDisabled retrieves if the snapshot maintenance is disabled.
|
||||
func ReadSnapshotDisabled(db ethdb.KeyValueReader) bool {
|
||||
disabled, _ := db.Has(snapshotDisabledKey)
|
||||
return disabled
|
||||
}
|
||||
|
||||
// WriteSnapshotDisabled stores the snapshot pause flag.
|
||||
func WriteSnapshotDisabled(db ethdb.KeyValueWriter) {
|
||||
if err := db.Put(snapshotDisabledKey, []byte("42")); err != nil {
|
||||
log.Crit("Failed to store snapshot disabled flag", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteSnapshotDisabled deletes the flag keeping the snapshot maintenance disabled.
|
||||
func DeleteSnapshotDisabled(db ethdb.KeyValueWriter) {
|
||||
if err := db.Delete(snapshotDisabledKey); err != nil {
|
||||
log.Crit("Failed to remove snapshot disabled flag", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
// ReadSnapshotRoot retrieves the root of the block whose state is contained in
|
||||
// the persisted snapshot.
|
||||
func ReadSnapshotRoot(db ethdb.KeyValueReader) common.Hash {
|
||||
|
@ -371,9 +371,9 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
|
||||
var accounted bool
|
||||
for _, meta := range [][]byte{
|
||||
databaseVersionKey, headHeaderKey, headBlockKey, headFastBlockKey, lastPivotKey,
|
||||
fastTrieProgressKey, snapshotRootKey, snapshotJournalKey, snapshotGeneratorKey,
|
||||
snapshotRecoveryKey, txIndexTailKey, fastTxLookupLimitKey, uncleanShutdownKey,
|
||||
badBlockKey,
|
||||
fastTrieProgressKey, snapshotDisabledKey, snapshotRootKey, snapshotJournalKey,
|
||||
snapshotGeneratorKey, snapshotRecoveryKey, txIndexTailKey, fastTxLookupLimitKey,
|
||||
uncleanShutdownKey, badBlockKey,
|
||||
} {
|
||||
if bytes.Equal(key, meta) {
|
||||
metadata.Add(size)
|
||||
|
@ -45,6 +45,9 @@ var (
|
||||
// fastTrieProgressKey tracks the number of trie entries imported during fast sync.
|
||||
fastTrieProgressKey = []byte("TrieSync")
|
||||
|
||||
// snapshotDisabledKey flags that the snapshot should not be maintained due to initial sync.
|
||||
snapshotDisabledKey = []byte("SnapshotDisabled")
|
||||
|
||||
// snapshotRootKey tracks the hash of the last snapshot.
|
||||
snapshotRootKey = []byte("SnapshotRoot")
|
||||
|
||||
|
Reference in New Issue
Block a user