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
b19bf3ec
Commit
b19bf3ec
authored
May 13, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: changed log message for forks. closes #952
parent
060a07cf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
chain_manager.go
core/chain_manager.go
+13
-11
No files found.
core/chain_manager.go
View file @
b19bf3ec
...
...
@@ -573,13 +573,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
if
block
.
Td
.
Cmp
(
self
.
td
)
>
0
{
// Check for chain forks. If H(block.num - 1) != block.parent, we're on a fork and need to do some merging
if
previous
:=
self
.
getBlockByNumber
(
block
.
NumberU64
()
-
1
);
previous
.
Hash
()
!=
block
.
ParentHash
()
{
chash
:=
cblock
.
Hash
()
hash
:=
block
.
Hash
()
if
glog
.
V
(
logger
.
Info
)
{
glog
.
Infof
(
"Split detected. New head #%v (%x) TD=%v, was #%v (%x) TD=%v
\n
"
,
block
.
Header
()
.
Number
,
hash
[
:
4
],
block
.
Td
,
cblock
.
Header
()
.
Number
,
chash
[
:
4
],
self
.
td
)
}
// during split we merge two different chains and create the new canonical chain
self
.
merge
(
previous
,
block
)
...
...
@@ -636,17 +629,21 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
// diff takes two blocks, an old chain and a new chain and will reconstruct the blocks and inserts them
// to be part of the new canonical chain.
func
(
self
*
ChainManager
)
diff
(
oldBlock
,
newBlock
*
types
.
Block
)
types
.
Blocks
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Applying diff to %x & %x
\n
"
,
oldBlock
.
Hash
()
.
Bytes
()[
:
4
],
newBlock
.
Hash
()
.
Bytes
()[
:
4
])
var
newChain
types
.
Blocks
var
(
newChain
types
.
Blocks
commonBlock
*
types
.
Block
oldStart
=
oldBlock
newStart
=
newBlock
)
// first find common number
for
newBlock
=
newBlock
;
newBlock
.
NumberU64
()
!=
oldBlock
.
NumberU64
();
newBlock
=
self
.
GetBlock
(
newBlock
.
ParentHash
())
{
newChain
=
append
(
newChain
,
newBlock
)
}
glog
.
V
(
logger
.
Debug
)
.
Infoln
(
"Found common number"
,
newBlock
.
Number
()
)
numSplit
:=
newBlock
.
Number
(
)
for
{
if
oldBlock
.
Hash
()
==
newBlock
.
Hash
()
{
commonBlock
=
oldBlock
break
}
newChain
=
append
(
newChain
,
newBlock
)
...
...
@@ -654,6 +651,11 @@ func (self *ChainManager) diff(oldBlock, newBlock *types.Block) types.Blocks {
oldBlock
,
newBlock
=
self
.
GetBlock
(
oldBlock
.
ParentHash
()),
self
.
GetBlock
(
newBlock
.
ParentHash
())
}
if
glog
.
V
(
logger
.
Info
)
{
commonHash
:=
commonBlock
.
Hash
()
glog
.
Infof
(
"Fork detected @ %x. Reorganising chain from #%v %x to %x"
,
commonHash
[
:
4
],
numSplit
,
oldStart
.
Hash
()
.
Bytes
()[
:
4
],
newStart
.
Hash
()
.
Bytes
()[
:
4
])
}
return
newChain
}
...
...
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