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
801a13f7
Commit
801a13f7
authored
Nov 28, 2016
by
Jeffrey Wilcke
Committed by
GitHub
Nov 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fixed unwinding bad hash (#3347)
Fixed unwinding of bad hashes when already on the canon chain
parent
eea8d6aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
blockchain.go
core/blockchain.go
+8
-3
No files found.
core/blockchain.go
View file @
801a13f7
...
...
@@ -152,9 +152,14 @@ func NewBlockChain(chainDb ethdb.Database, config *params.ChainConfig, pow pow.P
// Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain
for
hash
,
_
:=
range
BadHashes
{
if
header
:=
bc
.
GetHeaderByHash
(
hash
);
header
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"Found bad hash, rewinding chain to block #%d [%x…]"
,
header
.
Number
,
header
.
ParentHash
[
:
4
])
bc
.
SetHead
(
header
.
Number
.
Uint64
()
-
1
)
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"Chain rewind was successful, resuming normal operation"
)
// get the canonical block corresponding to the offending header's number
headerByNumber
:=
bc
.
GetHeaderByNumber
(
header
.
Number
.
Uint64
())
// make sure the headerByNumber (if present) is in our current canonical chain
if
headerByNumber
!=
nil
&&
headerByNumber
.
Hash
()
==
header
.
Hash
()
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"Found bad hash, rewinding chain to block #%d [%x…]"
,
header
.
Number
,
header
.
ParentHash
[
:
4
])
bc
.
SetHead
(
header
.
Number
.
Uint64
()
-
1
)
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"Chain rewind was successful, resuming normal operation"
)
}
}
}
// Take ownership of this particular state
...
...
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