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
d5cad488
Commit
d5cad488
authored
Jan 11, 2019
by
gary rong
Committed by
Péter Szilágyi
Jan 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core, eth: fix database version (#18429)
* core, eth: fix database version * eth: polish error message
parent
2eb838ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
10 deletions
+20
-10
blockchain.go
core/blockchain.go
+1
-1
accessors_metadata.go
core/rawdb/accessors_metadata.go
+15
-7
backend.go
eth/backend.go
+4
-2
No files found.
core/blockchain.go
View file @
d5cad488
...
@@ -65,7 +65,7 @@ const (
...
@@ -65,7 +65,7 @@ const (
triesInMemory
=
128
triesInMemory
=
128
// BlockChainVersion ensures that an incompatible database forces a resync from scratch.
// BlockChainVersion ensures that an incompatible database forces a resync from scratch.
BlockChainVersion
=
3
BlockChainVersion
uint64
=
3
)
)
// CacheConfig contains the configuration values for the trie caching/pruning
// CacheConfig contains the configuration values for the trie caching/pruning
...
...
core/rawdb/accessors_metadata.go
View file @
d5cad488
...
@@ -26,19 +26,27 @@ import (
...
@@ -26,19 +26,27 @@ import (
)
)
// ReadDatabaseVersion retrieves the version number of the database.
// ReadDatabaseVersion retrieves the version number of the database.
func
ReadDatabaseVersion
(
db
DatabaseReader
)
int
{
func
ReadDatabaseVersion
(
db
DatabaseReader
)
*
uint64
{
var
version
int
var
version
uint64
enc
,
_
:=
db
.
Get
(
databaseVerisionKey
)
enc
,
_
:=
db
.
Get
(
databaseVerisionKey
)
rlp
.
DecodeBytes
(
enc
,
&
version
)
if
len
(
enc
)
==
0
{
return
nil
}
if
err
:=
rlp
.
DecodeBytes
(
enc
,
&
version
);
err
!=
nil
{
return
nil
}
return
version
return
&
version
}
}
// WriteDatabaseVersion stores the version number of the database
// WriteDatabaseVersion stores the version number of the database
func
WriteDatabaseVersion
(
db
DatabaseWriter
,
version
int
)
{
func
WriteDatabaseVersion
(
db
DatabaseWriter
,
version
uint64
)
{
enc
,
_
:=
rlp
.
EncodeToBytes
(
version
)
enc
,
err
:=
rlp
.
EncodeToBytes
(
version
)
if
err
:=
db
.
Put
(
databaseVerisionKey
,
enc
);
err
!=
nil
{
if
err
!=
nil
{
log
.
Crit
(
"Failed to encode database version"
,
"err"
,
err
)
}
if
err
=
db
.
Put
(
databaseVerisionKey
,
enc
);
err
!=
nil
{
log
.
Crit
(
"Failed to store the database version"
,
"err"
,
err
)
log
.
Crit
(
"Failed to store the database version"
,
"err"
,
err
)
}
}
}
}
...
...
eth/backend.go
View file @
d5cad488
...
@@ -143,8 +143,10 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
...
@@ -143,8 +143,10 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
if
!
config
.
SkipBcVersionCheck
{
if
!
config
.
SkipBcVersionCheck
{
bcVersion
:=
rawdb
.
ReadDatabaseVersion
(
chainDb
)
bcVersion
:=
rawdb
.
ReadDatabaseVersion
(
chainDb
)
if
bcVersion
!=
core
.
BlockChainVersion
&&
bcVersion
!=
0
{
if
bcVersion
!=
nil
&&
*
bcVersion
>
core
.
BlockChainVersion
{
return
nil
,
fmt
.
Errorf
(
"Blockchain DB version mismatch (%d / %d).
\n
"
,
bcVersion
,
core
.
BlockChainVersion
)
return
nil
,
fmt
.
Errorf
(
"database version is v%d, Geth %s only supports v%d"
,
*
bcVersion
,
params
.
VersionWithMeta
,
core
.
BlockChainVersion
)
}
else
if
bcVersion
!=
nil
&&
*
bcVersion
<
core
.
BlockChainVersion
{
log
.
Warn
(
"Upgrade blockchain database version"
,
"from"
,
*
bcVersion
,
"to"
,
core
.
BlockChainVersion
)
}
}
rawdb
.
WriteDatabaseVersion
(
chainDb
,
core
.
BlockChainVersion
)
rawdb
.
WriteDatabaseVersion
(
chainDb
,
core
.
BlockChainVersion
)
}
}
...
...
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