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
6f3cb129
Commit
6f3cb129
authored
Sep 17, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: allow modifying test-chain block times
parent
58fbcaa7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
chain_makers.go
core/chain_makers.go
+11
-0
No files found.
core/chain_makers.go
View file @
6f3cb129
...
...
@@ -131,6 +131,17 @@ func (b *BlockGen) PrevBlock(index int) *types.Block {
return
b
.
chain
[
index
]
}
// OffsetTime modifies the time instance of a block, implicitly changing its
// associated difficulty. It's useful to test scenarios where forking is not
// tied to chain length directly.
func
(
b
*
BlockGen
)
OffsetTime
(
seconds
int64
)
{
b
.
header
.
Time
.
Add
(
b
.
header
.
Time
,
new
(
big
.
Int
)
.
SetInt64
(
seconds
))
if
b
.
header
.
Time
.
Cmp
(
b
.
parent
.
Header
()
.
Time
)
<=
0
{
panic
(
"block time out of range"
)
}
b
.
header
.
Difficulty
=
CalcDifficulty
(
b
.
header
.
Time
.
Uint64
(),
b
.
parent
.
Time
()
.
Uint64
(),
b
.
parent
.
Number
(),
b
.
parent
.
Difficulty
())
}
// GenerateChain creates a chain of n blocks. The first block's
// parent will be the provided parent. db is used to store
// intermediate states and should contain the parent's state trie.
...
...
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