diff --git a/core/blockchain.go b/core/blockchain.go index 0406f7a472..cf8cf5987c 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -133,8 +133,8 @@ type CacheConfig struct { TrieTimeLimit time.Duration // Time limit after which to flush the current in-memory trie to disk SnapshotLimit int // Memory allowance (MB) to use for caching snapshot entries in memory Preimages bool // Whether to store preimage of trie key to the disk - AllowForceUpdate bool // Enable to force snapshots based on commit counts - CommitThreshold int // Number of commits to force a root snapshot + AllowForceUpdate bool // Enable to force root snapshots based on the configured commits threshold + CommitThreshold int // Threshold of commits to force a root snapshot update SnapshotWait bool // Wait for snapshot construction on startup. TODO(karalabe): This is a dirty hack for testing, nuke it } diff --git a/core/state/snapshot/difflayer.go b/core/state/snapshot/difflayer.go index c25984baa9..220b8edeba 100644 --- a/core/state/snapshot/difflayer.go +++ b/core/state/snapshot/difflayer.go @@ -76,7 +76,7 @@ var ( bloomAccountHasherOffset = 0 bloomStorageHasherOffset = 0 - // Count for number of commits before fore disk root update + // Count for number of commits before forcing disk root update defaultCommitThreshold = 128 ) diff --git a/core/state/snapshot/snapshot.go b/core/state/snapshot/snapshot.go index 4047797287..06259b76e2 100644 --- a/core/state/snapshot/snapshot.go +++ b/core/state/snapshot/snapshot.go @@ -153,8 +153,8 @@ type Config struct { Recovery bool // Indicator that the snapshots is in the recovery mode ReBuild bool // Indicator that the snapshots generation is disallowed AsyncBuild bool // The snapshot generation is allowed to be constructed asynchronously - AllowForceUpdate bool // Enable forcing snap root generation on a commit count - CommitThreshold int // Number of commit after which to attempt snap root update + AllowForceUpdate bool // Enable to force root snapshots based on the configured commits threshold + CommitThreshold int // Threshold of commits to force a root snapshot update } // sanitize checks the provided user configurations and changes anything that's @@ -163,7 +163,7 @@ func (c *Config) sanitize() Config { conf := *c if conf.CommitThreshold == 0 { - log.Warn("Sanitizing invalid commit threshold to default", "defaultThreshold", defaultCommitThreshold) + log.Warn("Sanitizing commit threshold", "provided", conf.CommitThreshold, "updated", defaultCommitThreshold) conf.CommitThreshold = defaultCommitThreshold } return conf @@ -198,12 +198,10 @@ type Tree struct { // continuous with disk layer or the journal is missing, all diffs will be discarded // iff it's in "recovery" mode, otherwise rebuild is mandatory. func New(config Config, diskdb ethdb.KeyValueStore, triedb *trie.Database, root common.Hash) (*Tree, error) { - // apply default to config and fix invalid values - conf := config.sanitize() // Create a new, empty snapshot tree snap := &Tree{ - config: conf, + config: config.sanitize(), diskdb: diskdb, triedb: triedb, cache: config.CacheSize,