Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
00fead91
Unverified
Commit
00fead91
authored
Aug 23, 2023
by
Péter Szilágyi
Committed by
GitHub
Aug 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/utils: fix a startup issue on deleted chaindata but dangling ancients (#27989)
parent
bce5c467
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
flags.go
cmd/utils/flags.go
+3
-3
database.go
core/rawdb/database.go
+3
-3
No files found.
cmd/utils/flags.go
View file @
00fead91
...
@@ -2073,10 +2073,10 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly bool) ethdb.
...
@@ -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,
// tryMakeReadOnlyDatabase try to open the chain database in read-only mode,
// or fallback to write mode if the database is not initialized.
// or fallback to write mode if the database is not initialized.
func
tryMakeReadOnlyDatabase
(
ctx
*
cli
.
Context
,
stack
*
node
.
Node
)
ethdb
.
Database
{
func
tryMakeReadOnlyDatabase
(
ctx
*
cli
.
Context
,
stack
*
node
.
Node
)
ethdb
.
Database
{
// If
datadir doesn't exist we need to open db in write-mode
// If
the database doesn't exist we need to open it in write-mode to allow
//
so database engine can
create files.
//
the engine to
create files.
readonly
:=
true
readonly
:=
true
if
!
common
.
FileExist
(
stack
.
ResolvePath
(
"chaindata"
))
{
if
rawdb
.
PreexistingDatabase
(
stack
.
ResolvePath
(
"chaindata"
))
==
""
{
readonly
=
false
readonly
=
false
}
}
return
MakeChainDatabase
(
ctx
,
stack
,
readonly
)
return
MakeChainDatabase
(
ctx
,
stack
,
readonly
)
...
...
core/rawdb/database.go
View file @
00fead91
...
@@ -326,10 +326,10 @@ const (
...
@@ -326,10 +326,10 @@ const (
dbLeveldb
=
"leveldb"
dbLeveldb
=
"leveldb"
)
)
//
hasPreexistingDb
checks the given data directory whether a database is already
//
PreexistingDatabase
checks the given data directory whether a database is already
// instantiated at that location, and if so, returns the type of database (or the
// instantiated at that location, and if so, returns the type of database (or the
// empty string).
// empty string).
func
hasPreexistingDb
(
path
string
)
string
{
func
PreexistingDatabase
(
path
string
)
string
{
if
_
,
err
:=
os
.
Stat
(
filepath
.
Join
(
path
,
"CURRENT"
));
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
filepath
.
Join
(
path
,
"CURRENT"
));
err
!=
nil
{
return
""
// No pre-existing db
return
""
// No pre-existing db
}
}
...
@@ -367,7 +367,7 @@ func openKeyValueDatabase(o OpenOptions) (ethdb.Database, error) {
...
@@ -367,7 +367,7 @@ func openKeyValueDatabase(o OpenOptions) (ethdb.Database, error) {
}
}
// Retrieve any pre-existing database's type and use that or the requested one
// Retrieve any pre-existing database's type and use that or the requested one
// as long as there's no conflict between the two types
// as long as there's no conflict between the two types
existingDb
:=
hasPreexistingDb
(
o
.
Directory
)
existingDb
:=
PreexistingDatabase
(
o
.
Directory
)
if
len
(
existingDb
)
!=
0
&&
len
(
o
.
Type
)
!=
0
&&
o
.
Type
!=
existingDb
{
if
len
(
existingDb
)
!=
0
&&
len
(
o
.
Type
)
!=
0
&&
o
.
Type
!=
existingDb
{
return
nil
,
fmt
.
Errorf
(
"db.engine choice was %v but found pre-existing %v database in specified data directory"
,
o
.
Type
,
existingDb
)
return
nil
,
fmt
.
Errorf
(
"db.engine choice was %v but found pre-existing %v database in specified data directory"
,
o
.
Type
,
existingDb
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment