cmd/utils: fix a startup issue on deleted chaindata but dangling ancients (#27989)

This commit is contained in:
Péter Szilágyi
2023-08-23 16:42:37 +03:00
committed by GitHub
parent bce5c46739
commit 00fead91c4
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -2073,10 +2073,10 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly bool) ethdb.
// tryMakeReadOnlyDatabase try to open the chain database in read-only mode,
// or fallback to write mode if the database is not initialized.
func tryMakeReadOnlyDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database {
// If datadir doesn't exist we need to open db in write-mode
// so database engine can create files.
// If the database doesn't exist we need to open it in write-mode to allow
// the engine to create files.
readonly := true
if !common.FileExist(stack.ResolvePath("chaindata")) {
if rawdb.PreexistingDatabase(stack.ResolvePath("chaindata")) == "" {
readonly = false
}
return MakeChainDatabase(ctx, stack, readonly)