cmd/utils: tryMakeReadOnlyDB check with frdb

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2023-09-26 08:02:02 +08:00
parent 4fffad5d23
commit 38c200209a

View file

@ -2082,6 +2082,17 @@ func tryMakeReadOnlyDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database
if rawdb.PreexistingDatabase(stack.ResolvePath("chaindata")) == "" {
readonly = false
}
// If the freeze database is not initialized or corrupted,
// we need to open it in write-mode to apply the initialization or repair process
if readonly && !ctx.IsSet(RemoteDBFlag.Name) && ctx.String(SyncModeFlag.Name) != "light" {
ancient := stack.ResolveAncient("chaindata", ctx.String(AncientFlag.Name))
frdb, err := rawdb.NewChainFreezer(ancient, "", readonly)
if err != nil {
readonly = false
}
frdb.Close()
}
return MakeChainDatabase(ctx, stack, readonly)
}