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
c1c895a3
Commit
c1c895a3
authored
9 years ago
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fixed genesis write out to write only canon number
parent
73a576c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
chain_util.go
core/chain_util.go
+11
-2
genesis.go
core/genesis.go
+8
-1
No files found.
core/chain_util.go
View file @
c1c895a3
...
...
@@ -111,13 +111,22 @@ func GetBlockByNumber(db common.Database, number uint64) *types.Block {
return
GetBlockByHash
(
db
,
common
.
BytesToHash
(
key
))
}
// Write
Head force writes the current head
func
Write
Head
(
db
common
.
Database
,
block
*
types
.
Block
)
error
{
// Write
CanonNumber writes the canonical hash for the given block
func
Write
CanonNumber
(
db
common
.
Database
,
block
*
types
.
Block
)
error
{
key
:=
append
(
blockNumPre
,
block
.
Number
()
.
Bytes
()
...
)
err
:=
db
.
Put
(
key
,
block
.
Hash
()
.
Bytes
())
if
err
!=
nil
{
return
err
}
return
nil
}
// WriteHead force writes the current head
func
WriteHead
(
db
common
.
Database
,
block
*
types
.
Block
)
error
{
err
:=
WriteCanonNumber
(
db
,
block
)
if
err
!=
nil
{
return
err
}
err
=
db
.
Put
([]
byte
(
"LastBlock"
),
block
.
Hash
()
.
Bytes
())
if
err
!=
nil
{
return
err
...
...
This diff is collapsed.
Click to expand it.
core/genesis.go
View file @
c1c895a3
...
...
@@ -27,6 +27,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/params"
)
...
...
@@ -83,7 +85,12 @@ func WriteGenesisBlock(stateDb, blockDb common.Database, reader io.Reader) (*typ
block
.
Td
=
difficulty
if
block
:=
GetBlockByHash
(
blockDb
,
block
.
Hash
());
block
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Block %x already in database"
,
block
.
Hash
())
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"Genesis block already in chain. Writing canonical number"
)
err
:=
WriteCanonNumber
(
blockDb
,
block
)
if
err
!=
nil
{
return
nil
,
err
}
return
block
,
nil
}
statedb
.
Sync
()
...
...
This diff is collapsed.
Click to expand it.
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