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
46bcd9a9
Unverified
Commit
46bcd9a9
authored
Feb 28, 2017
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core, eth: drop database block splitting upgrader
parent
dbd88a1a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
80 deletions
+0
-80
database_util.go
core/database_util.go
+0
-18
backend.go
eth/backend.go
+0
-3
db_upgrade.go
eth/db_upgrade.go
+0
-59
No files found.
core/database_util.go
View file @
46bcd9a9
...
@@ -539,24 +539,6 @@ func DeleteReceipt(db ethdb.Database, hash common.Hash) {
...
@@ -539,24 +539,6 @@ func DeleteReceipt(db ethdb.Database, hash common.Hash) {
db
.
Delete
(
append
(
receiptsPrefix
,
hash
.
Bytes
()
...
))
db
.
Delete
(
append
(
receiptsPrefix
,
hash
.
Bytes
()
...
))
}
}
// [deprecated by the header/block split, remove eventually]
// GetBlockByHashOld returns the old combined block corresponding to the hash
// or nil if not found. This method is only used by the upgrade mechanism to
// access the old combined block representation. It will be dropped after the
// network transitions to eth/63.
func
GetBlockByHashOld
(
db
ethdb
.
Database
,
hash
common
.
Hash
)
*
types
.
Block
{
data
,
_
:=
db
.
Get
(
append
(
oldBlockHashPrefix
,
hash
[
:
]
...
))
if
len
(
data
)
==
0
{
return
nil
}
var
block
types
.
StorageBlock
if
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
data
),
&
block
);
err
!=
nil
{
log
.
Error
(
fmt
.
Sprintf
(
"invalid block RLP for hash %x: %v"
,
hash
,
err
))
return
nil
}
return
(
*
types
.
Block
)(
&
block
)
}
// returns a formatted MIP mapped key by adding prefix, canonical number and level
// returns a formatted MIP mapped key by adding prefix, canonical number and level
//
//
// ex. fn(98, 1000) = (prefix || 1000 || 0)
// ex. fn(98, 1000) = (prefix || 1000 || 0)
...
...
eth/backend.go
View file @
46bcd9a9
...
@@ -176,9 +176,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
...
@@ -176,9 +176,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
solcPath
:
config
.
SolcPath
,
solcPath
:
config
.
SolcPath
,
}
}
if
err
:=
upgradeChainDatabase
(
chainDb
);
err
!=
nil
{
return
nil
,
err
}
if
err
:=
addMipmapBloomBins
(
chainDb
);
err
!=
nil
{
if
err
:=
addMipmapBloomBins
(
chainDb
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
eth/db_upgrade.go
View file @
46bcd9a9
...
@@ -252,65 +252,6 @@ func upgradeSequentialBlockData(db ethdb.Database, hash []byte) error {
...
@@ -252,65 +252,6 @@ func upgradeSequentialBlockData(db ethdb.Database, hash []byte) error {
return
nil
return
nil
}
}
// upgradeChainDatabase ensures that the chain database stores block split into
// separate header and body entries.
func
upgradeChainDatabase
(
db
ethdb
.
Database
)
error
{
// Short circuit if the head block is stored already as separate header and body
data
,
err
:=
db
.
Get
([]
byte
(
"LastBlock"
))
if
err
!=
nil
{
return
nil
}
head
:=
common
.
BytesToHash
(
data
)
if
block
:=
core
.
GetBlockByHashOld
(
db
,
head
);
block
==
nil
{
return
nil
}
// At least some of the database is still the old format, upgrade (skip the head block!)
log
.
Info
(
fmt
.
Sprint
(
"Old database detected, upgrading..."
))
if
db
,
ok
:=
db
.
(
*
ethdb
.
LDBDatabase
);
ok
{
blockPrefix
:=
[]
byte
(
"block-hash-"
)
for
it
:=
db
.
NewIterator
();
it
.
Next
();
{
// Skip anything other than a combined block
if
!
bytes
.
HasPrefix
(
it
.
Key
(),
blockPrefix
)
{
continue
}
// Skip the head block (merge last to signal upgrade completion)
if
bytes
.
HasSuffix
(
it
.
Key
(),
head
.
Bytes
())
{
continue
}
// Load the block, split and serialize (order!)
block
:=
core
.
GetBlockByHashOld
(
db
,
common
.
BytesToHash
(
bytes
.
TrimPrefix
(
it
.
Key
(),
blockPrefix
)))
if
err
:=
core
.
WriteTd
(
db
,
block
.
Hash
(),
block
.
NumberU64
(),
block
.
DeprecatedTd
());
err
!=
nil
{
return
err
}
if
err
:=
core
.
WriteBody
(
db
,
block
.
Hash
(),
block
.
NumberU64
(),
block
.
Body
());
err
!=
nil
{
return
err
}
if
err
:=
core
.
WriteHeader
(
db
,
block
.
Header
());
err
!=
nil
{
return
err
}
if
err
:=
db
.
Delete
(
it
.
Key
());
err
!=
nil
{
return
err
}
}
// Lastly, upgrade the head block, disabling the upgrade mechanism
current
:=
core
.
GetBlockByHashOld
(
db
,
head
)
if
err
:=
core
.
WriteTd
(
db
,
current
.
Hash
(),
current
.
NumberU64
(),
current
.
DeprecatedTd
());
err
!=
nil
{
return
err
}
if
err
:=
core
.
WriteBody
(
db
,
current
.
Hash
(),
current
.
NumberU64
(),
current
.
Body
());
err
!=
nil
{
return
err
}
if
err
:=
core
.
WriteHeader
(
db
,
current
.
Header
());
err
!=
nil
{
return
err
}
}
return
nil
}
func
addMipmapBloomBins
(
db
ethdb
.
Database
)
(
err
error
)
{
func
addMipmapBloomBins
(
db
ethdb
.
Database
)
(
err
error
)
{
const
mipmapVersion
uint
=
2
const
mipmapVersion
uint
=
2
...
...
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