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
13699e2d
Commit
13699e2d
authored
Oct 05, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1877 from obscuren/head-write
core: fixed head write on block insertion
parents
5b34fa53
20ab29f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
blockchain.go
core/blockchain.go
+3
-0
blockchain_test.go
core/blockchain_test.go
+13
-0
No files found.
core/blockchain.go
View file @
13699e2d
...
...
@@ -297,6 +297,9 @@ func (bc *BlockChain) insert(block *types.Block) {
if
err
:=
WriteCanonicalHash
(
bc
.
chainDb
,
block
.
Hash
(),
block
.
NumberU64
());
err
!=
nil
{
glog
.
Fatalf
(
"failed to insert block number: %v"
,
err
)
}
if
err
:=
WriteHeadBlockHash
(
bc
.
chainDb
,
block
.
Hash
());
err
!=
nil
{
glog
.
Fatalf
(
"failed to insert block number: %v"
,
err
)
}
bc
.
currentBlock
=
block
}
...
...
core/blockchain_test.go
View file @
13699e2d
...
...
@@ -153,6 +153,19 @@ func insertChain(done chan bool, blockchain *BlockChain, chain types.Blocks, t *
done
<-
true
}
func
TestLastBlock
(
t
*
testing
.
T
)
{
db
,
err
:=
ethdb
.
NewMemDatabase
()
if
err
!=
nil
{
t
.
Fatal
(
"Failed to create db:"
,
err
)
}
bchain
:=
theBlockChain
(
db
,
t
)
block
:=
makeChain
(
bchain
.
CurrentBlock
(),
1
,
db
,
0
)[
0
]
bchain
.
insert
(
block
)
if
block
.
Hash
()
!=
GetHeadBlockHash
(
db
)
{
t
.
Errorf
(
"Write/Get HeadBlockHash failed"
)
}
}
func
TestExtendCanonical
(
t
*
testing
.
T
)
{
CanonicalLength
:=
5
db
,
err
:=
ethdb
.
NewMemDatabase
()
...
...
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