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
7efb12d2
Unverified
Commit
7efb12d2
authored
Sep 17, 2018
by
Martin Holst Swende
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ethash: documentation + cleanup
parent
3df7df03
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
consensus.go
consensus/ethash/consensus.go
+13
-8
No files found.
consensus/ethash/consensus.go
View file @
7efb12d2
...
@@ -46,13 +46,16 @@ var (
...
@@ -46,13 +46,16 @@ var (
// calcDifficultyConstantinople is the difficulty adjustment algorithm for Constantinople.
// calcDifficultyConstantinople is the difficulty adjustment algorithm for Constantinople.
// It returns the difficulty that a new block should have when created at time given the
// It returns the difficulty that a new block should have when created at time given the
// parent block's time and difficulty. The calculation uses the Byzantium rules, but with bomb offset 5M.
// parent block's time and difficulty. The calculation uses the Byzantium rules, but with
calcDifficultyConstantinople
=
makeDifficultyCalculator
(
big
.
NewInt
(
4999999
))
// bomb offset 5M.
// Specification EIP-1234: https://eips.ethereum.org/EIPS/eip-1234
calcDifficultyConstantinople
=
makeDifficultyCalculator
(
big
.
NewInt
(
5000000
))
// calcDifficultyByzantium is the difficulty adjustment algorithm. It returns
// calcDifficultyByzantium is the difficulty adjustment algorithm. It returns
// the difficulty that a new block should have when created at time given the
// the difficulty that a new block should have when created at time given the
// parent block's time and difficulty. The calculation uses the Byzantium rules.
// parent block's time and difficulty. The calculation uses the Byzantium rules.
calcDifficultyByzantium
=
makeDifficultyCalculator
(
big
.
NewInt
(
2999999
))
// Specification EIP-649: https://eips.ethereum.org/EIPS/eip-649
calcDifficultyByzantium
=
makeDifficultyCalculator
(
big
.
NewInt
(
3000000
))
)
)
// Various error messages to mark blocks invalid. These should be private to
// Various error messages to mark blocks invalid. These should be private to
...
@@ -335,6 +338,9 @@ var (
...
@@ -335,6 +338,9 @@ var (
// the difficulty is calculated with Byzantium rules, which differs from Homestead in
// the difficulty is calculated with Byzantium rules, which differs from Homestead in
// how uncles affect the calculation
// how uncles affect the calculation
func
makeDifficultyCalculator
(
bombDelay
*
big
.
Int
)
func
(
time
uint64
,
parent
*
types
.
Header
)
*
big
.
Int
{
func
makeDifficultyCalculator
(
bombDelay
*
big
.
Int
)
func
(
time
uint64
,
parent
*
types
.
Header
)
*
big
.
Int
{
// Note, the calculations below looks at the parent number, which is 1 below
// the block number. Thus we remove one from the delay given
bombDelayFromParent
:=
new
(
big
.
Int
)
.
Sub
(
bombDelay
,
big1
)
return
func
(
time
uint64
,
parent
*
types
.
Header
)
*
big
.
Int
{
return
func
(
time
uint64
,
parent
*
types
.
Header
)
*
big
.
Int
{
// https://github.com/ethereum/EIPs/issues/100.
// https://github.com/ethereum/EIPs/issues/100.
// algorithm:
// algorithm:
...
@@ -370,12 +376,11 @@ func makeDifficultyCalculator(bombDelay *big.Int) func(time uint64, parent *type
...
@@ -370,12 +376,11 @@ func makeDifficultyCalculator(bombDelay *big.Int) func(time uint64, parent *type
if
x
.
Cmp
(
params
.
MinimumDifficulty
)
<
0
{
if
x
.
Cmp
(
params
.
MinimumDifficulty
)
<
0
{
x
.
Set
(
params
.
MinimumDifficulty
)
x
.
Set
(
params
.
MinimumDifficulty
)
}
}
// calculate a fake block number for the ice-age delay:
// calculate a fake block number for the ice-age delay
// https://github.com/ethereum/EIPs/pull/669
// Specification: https://eips.ethereum.org/EIPS/eip-1234
// fake_block_number = max(0, block.number - 3_000_000)
fakeBlockNumber
:=
new
(
big
.
Int
)
fakeBlockNumber
:=
new
(
big
.
Int
)
if
parent
.
Number
.
Cmp
(
bombDelay
)
>=
0
{
if
parent
.
Number
.
Cmp
(
bombDelay
FromParent
)
>=
0
{
fakeBlockNumber
=
fakeBlockNumber
.
Sub
(
parent
.
Number
,
bombDelay
)
// Note, parent is 1 less than the actual block number
fakeBlockNumber
=
fakeBlockNumber
.
Sub
(
parent
.
Number
,
bombDelay
FromParent
)
}
}
// for the exponential factor
// for the exponential factor
periodCount
:=
fakeBlockNumber
periodCount
:=
fakeBlockNumber
...
...
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