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
8b84bd28
Commit
8b84bd28
authored
Aug 03, 2017
by
Péter Szilágyi
Committed by
GitHub
Aug 03, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14889 from karalabe/ethash-cache-on-import
cmd: add makecache cmd, use caches during import cmd
parents
4371367c
4a260dc1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
27 deletions
+42
-27
main.go
cmd/geth/main.go
+1
-0
misccmd.go
cmd/geth/misccmd.go
+37
-26
flags.go
cmd/utils/flags.go
+4
-1
No files found.
cmd/geth/main.go
View file @
8b84bd28
...
...
@@ -157,6 +157,7 @@ func init() {
attachCommand
,
javascriptCommand
,
// See misccmd.go:
makecacheCommand
,
makedagCommand
,
versionCommand
,
bugCommand
,
...
...
cmd/geth/misccmd.go
View file @
8b84bd28
...
...
@@ -18,9 +18,7 @@ package main
import
(
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
...
...
@@ -33,14 +31,27 @@ import (
)
var
(
makecacheCommand
=
cli
.
Command
{
Action
:
utils
.
MigrateFlags
(
makecache
),
Name
:
"makecache"
,
Usage
:
"Generate ethash verification cache (for testing)"
,
ArgsUsage
:
"<blockNum> <outputDir>"
,
Category
:
"MISCELLANEOUS COMMANDS"
,
Description
:
`
The makecache command generates an ethash cache in <outputDir>.
This command exists to support the system testing project.
Regular users do not need to execute it.
`
,
}
makedagCommand
=
cli
.
Command
{
Action
:
utils
.
MigrateFlags
(
makedag
),
Name
:
"makedag"
,
Usage
:
"Generate ethash DAG (for testing)"
,
Usage
:
"Generate ethash
mining
DAG (for testing)"
,
ArgsUsage
:
"<blockNum> <outputDir>"
,
Category
:
"MISCELLANEOUS COMMANDS"
,
Description
:
`
The makedag command generates an ethash DAG in
/tmp/dag
.
The makedag command generates an ethash DAG in
<outputDir>
.
This command exists to support the system testing project.
Regular users do not need to execute it.
...
...
@@ -65,33 +76,33 @@ The output of this command is supposed to be machine-readable.
}
)
func
makedag
(
ctx
*
cli
.
Context
)
error
{
// makecache generates an ethash verification cache into the provided folder.
func
makecache
(
ctx
*
cli
.
Context
)
error
{
args
:=
ctx
.
Args
()
wrongArgs
:=
func
()
{
utils
.
Fatalf
(
`Usage: geth make
dag
<block number> <outputdir>`
)
if
len
(
args
)
!=
2
{
utils
.
Fatalf
(
`Usage: geth make
cache
<block number> <outputdir>`
)
}
switch
{
case
len
(
args
)
==
2
:
blockNum
,
err
:=
strconv
.
ParseUint
(
args
[
0
],
0
,
64
)
dir
:=
args
[
1
]
block
,
err
:=
strconv
.
ParseUint
(
args
[
0
],
0
,
64
)
if
err
!=
nil
{
wrongArgs
()
}
else
{
dir
=
filepath
.
Clean
(
dir
)
// seems to require a trailing slash
if
!
strings
.
HasSuffix
(
dir
,
"/"
)
{
dir
=
dir
+
"/"
utils
.
Fatalf
(
"Invalid block number: %v"
,
err
)
}
_
,
err
=
ioutil
.
ReadDir
(
dir
)
if
err
!=
nil
{
utils
.
Fatalf
(
"Can't find dir"
)
}
fmt
.
Println
(
"making DAG, this could take awhile..."
)
ethash
.
MakeDataset
(
blockNum
,
dir
)
ethash
.
MakeCache
(
block
,
args
[
1
])
return
nil
}
// makedag generates an ethash mining DAG into the provided folder.
func
makedag
(
ctx
*
cli
.
Context
)
error
{
args
:=
ctx
.
Args
()
if
len
(
args
)
!=
2
{
utils
.
Fatalf
(
`Usage: geth makedag <block number> <outputdir>`
)
}
default
:
wrongArgs
()
block
,
err
:=
strconv
.
ParseUint
(
args
[
0
],
0
,
64
)
if
err
!=
nil
{
utils
.
Fatalf
(
"Invalid block number: %v"
,
err
)
}
ethash
.
MakeDataset
(
block
,
args
[
1
])
return
nil
}
...
...
cmd/utils/flags.go
View file @
8b84bd28
...
...
@@ -1093,7 +1093,10 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
engine
:=
ethash
.
NewFaker
()
if
!
ctx
.
GlobalBool
(
FakePoWFlag
.
Name
)
{
engine
=
ethash
.
New
(
""
,
1
,
0
,
""
,
1
,
0
)
engine
=
ethash
.
New
(
stack
.
ResolvePath
(
eth
.
DefaultConfig
.
EthashCacheDir
),
eth
.
DefaultConfig
.
EthashCachesInMem
,
eth
.
DefaultConfig
.
EthashCachesOnDisk
,
stack
.
ResolvePath
(
eth
.
DefaultConfig
.
EthashDatasetDir
),
eth
.
DefaultConfig
.
EthashDatasetsInMem
,
eth
.
DefaultConfig
.
EthashDatasetsOnDisk
,
)
}
config
,
_
,
err
:=
core
.
SetupGenesisBlock
(
chainDb
,
MakeGenesis
(
ctx
))
if
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