good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
c1c895a3
Commit
c1c895a3
authored
Jul 25, 2015
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
core: fixed genesis write out to write only canon number
parent
73a576c9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/chain_util.go
+11
-2
11 additions, 2 deletions
core/chain_util.go
core/genesis.go
+8
-1
8 additions, 1 deletion
core/genesis.go
with
19 additions
and
3 deletions
core/chain_util.go
+
11
−
2
View file @
c1c895a3
...
@@ -111,13 +111,22 @@ func GetBlockByNumber(db common.Database, number uint64) *types.Block {
...
@@ -111,13 +111,22 @@ func GetBlockByNumber(db common.Database, number uint64) *types.Block {
return
GetBlockByHash
(
db
,
common
.
BytesToHash
(
key
))
return
GetBlockByHash
(
db
,
common
.
BytesToHash
(
key
))
}
}
// Write
Head force
writes the c
urrent head
// Write
CanonNumber
writes the c
anonical hash for the given block
func
Write
Head
(
db
common
.
Database
,
block
*
types
.
Block
)
error
{
func
Write
CanonNumber
(
db
common
.
Database
,
block
*
types
.
Block
)
error
{
key
:=
append
(
blockNumPre
,
block
.
Number
()
.
Bytes
()
...
)
key
:=
append
(
blockNumPre
,
block
.
Number
()
.
Bytes
()
...
)
err
:=
db
.
Put
(
key
,
block
.
Hash
()
.
Bytes
())
err
:=
db
.
Put
(
key
,
block
.
Hash
()
.
Bytes
())
if
err
!=
nil
{
if
err
!=
nil
{
return
err
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
())
err
=
db
.
Put
([]
byte
(
"LastBlock"
),
block
.
Hash
()
.
Bytes
())
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
This diff is collapsed.
Click to expand it.
core/genesis.go
+
8
−
1
View file @
c1c895a3
...
@@ -27,6 +27,8 @@ import (
...
@@ -27,6 +27,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"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"
"github.com/ethereum/go-ethereum/params"
)
)
...
@@ -83,7 +85,12 @@ func WriteGenesisBlock(stateDb, blockDb common.Database, reader io.Reader) (*typ
...
@@ -83,7 +85,12 @@ func WriteGenesisBlock(stateDb, blockDb common.Database, reader io.Reader) (*typ
block
.
Td
=
difficulty
block
.
Td
=
difficulty
if
block
:=
GetBlockByHash
(
blockDb
,
block
.
Hash
());
block
!=
nil
{
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
()
statedb
.
Sync
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment