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
5d6d40f3
Commit
5d6d40f3
authored
Jul 08, 2015
by
Gustav Simonsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use uint64 on ts in chain_manager, block_processor
parent
b08abe64
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
6 deletions
+12
-6
block_processor.go
core/block_processor.go
+1
-1
chain_makers.go
core/chain_makers.go
+1
-1
chain_manager.go
core/chain_manager.go
+1
-1
chain_util.go
core/chain_util.go
+8
-2
worker.go
miner/worker.go
+1
-1
No files found.
core/block_processor.go
View file @
5d6d40f3
...
...
@@ -386,7 +386,7 @@ func ValidateHeader(pow pow.PoW, block *types.Header, parent *types.Block, check
return
BlockEqualTSErr
}
expd
:=
CalcDifficulty
(
int64
(
block
.
Time
),
int64
(
parent
.
Time
()
),
parent
.
Difficulty
())
expd
:=
CalcDifficulty
(
block
.
Time
,
parent
.
Time
(
),
parent
.
Difficulty
())
if
expd
.
Cmp
(
block
.
Difficulty
)
!=
0
{
return
fmt
.
Errorf
(
"Difficulty check failed for block %v, %v"
,
block
.
Difficulty
,
expd
)
}
...
...
core/chain_makers.go
View file @
5d6d40f3
...
...
@@ -171,7 +171,7 @@ func makeHeader(parent *types.Block, state *state.StateDB) *types.Header {
Root
:
state
.
Root
(),
ParentHash
:
parent
.
Hash
(),
Coinbase
:
parent
.
Coinbase
(),
Difficulty
:
CalcDifficulty
(
int64
(
time
),
int64
(
parent
.
Time
()
),
parent
.
Difficulty
()),
Difficulty
:
CalcDifficulty
(
time
,
parent
.
Time
(
),
parent
.
Difficulty
()),
GasLimit
:
CalcGasLimit
(
parent
),
GasUsed
:
new
(
big
.
Int
),
Number
:
new
(
big
.
Int
)
.
Add
(
parent
.
Number
(),
common
.
Big1
),
...
...
core/chain_manager.go
View file @
5d6d40f3
...
...
@@ -611,7 +611,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
// Allow up to MaxFuture second in the future blocks. If this limit
// is exceeded the chain is discarded and processed at a later time
// if given.
if
max
:=
time
.
Now
()
.
Unix
()
+
maxTimeFutureBlocks
;
int64
(
block
.
Time
()
)
>
max
{
if
max
:=
uint64
(
time
.
Now
()
.
Unix
())
+
maxTimeFutureBlocks
;
block
.
Time
(
)
>
max
{
return
i
,
fmt
.
Errorf
(
"%v: BlockFutureErr, %v > %v"
,
BlockFutureErr
,
block
.
Time
(),
max
)
}
...
...
core/chain_util.go
View file @
5d6d40f3
...
...
@@ -31,10 +31,16 @@ import (
// CalcDifficulty is the difficulty adjustment algorithm. It returns
// the difficulty that a new block b should have when created at time
// given the parent block's time and difficulty.
func
CalcDifficulty
(
time
int64
,
parentTime
int64
,
parentDiff
*
big
.
Int
)
*
big
.
Int
{
func
CalcDifficulty
(
time
,
parentTime
u
int64
,
parentDiff
*
big
.
Int
)
*
big
.
Int
{
diff
:=
new
(
big
.
Int
)
adjust
:=
new
(
big
.
Int
)
.
Div
(
parentDiff
,
params
.
DifficultyBoundDivisor
)
if
big
.
NewInt
(
time
-
parentTime
)
.
Cmp
(
params
.
DurationLimit
)
<
0
{
bigTime
:=
new
(
big
.
Int
)
bigParentTime
:=
new
(
big
.
Int
)
bigTime
.
SetUint64
(
time
)
bigParentTime
.
SetUint64
(
parentTime
)
if
bigTime
.
Sub
(
bigTime
,
bigParentTime
)
.
Cmp
(
params
.
DurationLimit
)
<
0
{
diff
.
Add
(
parentDiff
,
adjust
)
}
else
{
diff
.
Sub
(
parentDiff
,
adjust
)
...
...
miner/worker.go
View file @
5d6d40f3
...
...
@@ -427,7 +427,7 @@ func (self *worker) commitNewWork() {
header
:=
&
types
.
Header
{
ParentHash
:
parent
.
Hash
(),
Number
:
num
.
Add
(
num
,
common
.
Big1
),
Difficulty
:
core
.
CalcDifficulty
(
int64
(
tstamp
),
int64
(
parent
.
Time
()
),
parent
.
Difficulty
()),
Difficulty
:
core
.
CalcDifficulty
(
uint64
(
tstamp
),
parent
.
Time
(
),
parent
.
Difficulty
()),
GasLimit
:
core
.
CalcGasLimit
(
parent
),
GasUsed
:
new
(
big
.
Int
),
Coinbase
:
self
.
coinbase
,
...
...
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