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
29181003
Commit
29181003
authored
Aug 14, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1655 from obscuren/db-merge-fix
eth, trie: removed key prefixing from state entries & merge db fix
parents
28b14d3e
b8ca0a83
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
21 deletions
+19
-21
backend.go
eth/backend.go
+19
-15
cache.go
trie/cache.go
+0
-4
trie.go
trie/trie.go
+0
-2
No files found.
eth/backend.go
View file @
29181003
...
@@ -45,7 +45,6 @@ import (
...
@@ -45,7 +45,6 @@ import (
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/whisper"
"github.com/ethereum/go-ethereum/whisper"
)
)
...
@@ -738,48 +737,53 @@ func mergeDatabases(datadir string, newdb func(path string) (common.Database, er
...
@@ -738,48 +737,53 @@ func mergeDatabases(datadir string, newdb func(path string) (common.Database, er
}
}
defer
database
.
Close
()
defer
database
.
Close
()
glog
.
Infoln
(
"Merging blockchain database..."
)
// Migrate blocks
chainDb
,
err
:=
newdb
(
chainPath
)
chainDb
,
err
:=
newdb
(
chainPath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"state db err: %v"
,
err
)
return
fmt
.
Errorf
(
"state db err: %v"
,
err
)
}
}
defer
chainDb
.
Close
()
defer
chainDb
.
Close
()
if
db
,
ok
:=
chainDb
.
(
*
ethdb
.
LDBDatabase
);
ok
{
if
chain
,
ok
:=
chainDb
.
(
*
ethdb
.
LDBDatabase
);
ok
{
it
:=
db
.
NewIterator
()
glog
.
Infoln
(
"Merging blockchain database..."
)
it
:=
chain
.
NewIterator
()
for
it
.
Next
()
{
for
it
.
Next
()
{
database
.
Put
(
it
.
Key
(),
it
.
Value
())
database
.
Put
(
it
.
Key
(),
it
.
Value
())
}
}
it
.
Release
()
}
}
glog
.
Infoln
(
"Merging state database..."
)
// Migrate state
state
:=
filepath
.
Join
(
datadir
,
"state"
)
stateDb
,
err
:=
newdb
(
filepath
.
Join
(
datadir
,
"state"
))
stateDb
,
err
:=
newdb
(
state
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"state db err: %v"
,
err
)
return
fmt
.
Errorf
(
"state db err: %v"
,
err
)
}
}
defer
stateDb
.
Close
()
defer
stateDb
.
Close
()
if
db
,
ok
:=
chainDb
.
(
*
ethdb
.
LDBDatabase
);
ok
{
if
state
,
ok
:=
stateDb
.
(
*
ethdb
.
LDBDatabase
);
ok
{
it
:=
db
.
NewIterator
()
glog
.
Infoln
(
"Merging state database..."
)
it
:=
state
.
NewIterator
()
for
it
.
Next
()
{
for
it
.
Next
()
{
database
.
Put
(
append
(
trie
.
StatePre
,
it
.
Key
()
...
),
it
.
Value
())
database
.
Put
(
it
.
Key
(
),
it
.
Value
())
}
}
it
.
Release
()
}
}
glog
.
Infoln
(
"Merging transaction database..."
)
// Migrate transaction / receipts
extra
:=
filepath
.
Join
(
datadir
,
"extra"
)
extraDb
,
err
:=
newdb
(
filepath
.
Join
(
datadir
,
"extra"
))
extraDb
,
err
:=
newdb
(
extra
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"state db err: %v"
,
err
)
return
fmt
.
Errorf
(
"state db err: %v"
,
err
)
}
}
defer
extraDb
.
Close
()
defer
extraDb
.
Close
()
if
db
,
ok
:=
chainDb
.
(
*
ethdb
.
LDBDatabase
);
ok
{
if
extra
,
ok
:=
extraDb
.
(
*
ethdb
.
LDBDatabase
);
ok
{
it
:=
db
.
NewIterator
()
glog
.
Infoln
(
"Merging transaction database..."
)
it
:=
extra
.
NewIterator
()
for
it
.
Next
()
{
for
it
.
Next
()
{
database
.
Put
(
it
.
Key
(),
it
.
Value
())
database
.
Put
(
it
.
Key
(),
it
.
Value
())
}
}
it
.
Release
()
}
}
return
nil
return
nil
...
...
trie/cache.go
View file @
29181003
...
@@ -38,8 +38,6 @@ func NewCache(backend Backend) *Cache {
...
@@ -38,8 +38,6 @@ func NewCache(backend Backend) *Cache {
}
}
func
(
self
*
Cache
)
Get
(
key
[]
byte
)
[]
byte
{
func
(
self
*
Cache
)
Get
(
key
[]
byte
)
[]
byte
{
key
=
append
(
StatePre
,
key
...
)
data
:=
self
.
store
[
string
(
key
)]
data
:=
self
.
store
[
string
(
key
)]
if
data
==
nil
{
if
data
==
nil
{
data
,
_
=
self
.
backend
.
Get
(
key
)
data
,
_
=
self
.
backend
.
Get
(
key
)
...
@@ -49,8 +47,6 @@ func (self *Cache) Get(key []byte) []byte {
...
@@ -49,8 +47,6 @@ func (self *Cache) Get(key []byte) []byte {
}
}
func
(
self
*
Cache
)
Put
(
key
[]
byte
,
data
[]
byte
)
{
func
(
self
*
Cache
)
Put
(
key
[]
byte
,
data
[]
byte
)
{
key
=
append
(
StatePre
,
key
...
)
self
.
batch
.
Put
(
key
,
data
)
self
.
batch
.
Put
(
key
,
data
)
self
.
store
[
string
(
key
)]
=
data
self
.
store
[
string
(
key
)]
=
data
}
}
...
...
trie/trie.go
View file @
29181003
...
@@ -27,8 +27,6 @@ import (
...
@@ -27,8 +27,6 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
)
)
var
StatePre
=
[]
byte
(
"state-"
)
func
ParanoiaCheck
(
t1
*
Trie
,
backend
Backend
)
(
bool
,
*
Trie
)
{
func
ParanoiaCheck
(
t1
*
Trie
,
backend
Backend
)
(
bool
,
*
Trie
)
{
t2
:=
New
(
nil
,
backend
)
t2
:=
New
(
nil
,
backend
)
...
...
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