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
801a13f7
Commit
801a13f7
authored
Nov 28, 2016
by
Jeffrey Wilcke
Committed by
GitHub
Nov 28, 2016
Browse files
Options
Downloads
Patches
Plain Diff
core: fixed unwinding bad hash (#3347)
Fixed unwinding of bad hashes when already on the canon chain
parent
eea8d6aa
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/blockchain.go
+8
-3
8 additions, 3 deletions
core/blockchain.go
with
8 additions
and
3 deletions
core/blockchain.go
+
8
−
3
View file @
801a13f7
...
@@ -152,11 +152,16 @@ func NewBlockChain(chainDb ethdb.Database, config *params.ChainConfig, pow pow.P
...
@@ -152,11 +152,16 @@ 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
// 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
{
for
hash
,
_
:=
range
BadHashes
{
if
header
:=
bc
.
GetHeaderByHash
(
hash
);
header
!=
nil
{
if
header
:=
bc
.
GetHeaderByHash
(
hash
);
header
!=
nil
{
// 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
])
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
)
bc
.
SetHead
(
header
.
Number
.
Uint64
()
-
1
)
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"Chain rewind was successful, resuming normal operation"
)
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"Chain rewind was successful, resuming normal operation"
)
}
}
}
}
}
// Take ownership of this particular state
// Take ownership of this particular state
go
bc
.
update
()
go
bc
.
update
()
return
bc
,
nil
return
bc
,
nil
...
...
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