cmd/utils: enable snapshot generation in import-mode (#25990)
This PR fixes a regression causing snapshots not to be generated in "geth --import" mode. It also fixes the geth export command to be truly readonly, and adds a new test for geth export.
This commit is contained in:
+6
-4
@@ -2217,10 +2217,10 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
|
||||
}
|
||||
|
||||
// MakeChain creates a chain manager from set command line flags.
|
||||
func MakeChain(ctx *cli.Context, stack *node.Node) (*core.BlockChain, ethdb.Database) {
|
||||
func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockChain, ethdb.Database) {
|
||||
var (
|
||||
gspec = MakeGenesis(ctx)
|
||||
chainDb = MakeChainDatabase(ctx, stack, false) // TODO(rjl493456442) support read-only database
|
||||
chainDb = MakeChainDatabase(ctx, stack, readonly)
|
||||
)
|
||||
cliqueConfig, err := core.LoadCliqueConfig(chainDb, gspec)
|
||||
if err != nil {
|
||||
@@ -2250,8 +2250,10 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (*core.BlockChain, ethdb.Data
|
||||
if !ctx.Bool(SnapshotFlag.Name) {
|
||||
cache.SnapshotLimit = 0 // Disabled
|
||||
}
|
||||
// Disable snapshot generation/wiping by default
|
||||
cache.SnapshotNoBuild = true
|
||||
// If we're in readonly, do not bother generating snapshot data.
|
||||
if readonly {
|
||||
cache.SnapshotNoBuild = true
|
||||
}
|
||||
|
||||
if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheTrieFlag.Name) {
|
||||
cache.TrieCleanLimit = ctx.Int(CacheFlag.Name) * ctx.Int(CacheTrieFlag.Name) / 100
|
||||
|
||||
Reference in New Issue
Block a user