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
43c8a191
Unverified
Commit
43c8a191
authored
Nov 15, 2017
by
Péter Szilágyi
Committed by
GitHub
Nov 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15470 from karalabe/clique-sametd-splitter
core: split same-td blocks on block height
parents
ba62215d
54ce3887
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
blockchain.go
core/blockchain.go
+6
-1
No files found.
core/blockchain.go
View file @
43c8a191
...
...
@@ -818,7 +818,12 @@ func (bc *BlockChain) WriteBlockAndState(block *types.Block, receipts []*types.R
// If the total difficulty is higher than our known, add it to the canonical chain
// Second clause in the if statement reduces the vulnerability to selfish mining.
// Please refer to http://www.cs.cornell.edu/~ie53/publications/btcProcFC.pdf
if
externTd
.
Cmp
(
localTd
)
>
0
||
(
externTd
.
Cmp
(
localTd
)
==
0
&&
mrand
.
Float64
()
<
0.5
)
{
reorg
:=
externTd
.
Cmp
(
localTd
)
>
0
if
!
reorg
&&
externTd
.
Cmp
(
localTd
)
==
0
{
// Split same-difficulty blocks by number, then at random
reorg
=
block
.
NumberU64
()
<
bc
.
currentBlock
.
NumberU64
()
||
(
block
.
NumberU64
()
==
bc
.
currentBlock
.
NumberU64
()
&&
mrand
.
Float64
()
<
0.5
)
}
if
reorg
{
// Reorganise the chain if the parent is not the head block
if
block
.
ParentHash
()
!=
bc
.
currentBlock
.
Hash
()
{
if
err
:=
bc
.
reorg
(
bc
.
currentBlock
,
block
);
err
!=
nil
{
...
...
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