Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
4a260dc1
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4a260dc1
编写于
8月 03, 2017
作者:
P
Péter Szilágyi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cmd: add makecache cmd, use caches during import cmd
上级
bc0e6a5e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
27 deletion
+42
-27
cmd/geth/main.go
cmd/geth/main.go
+1
-0
cmd/geth/misccmd.go
cmd/geth/misccmd.go
+37
-26
cmd/utils/flags.go
cmd/utils/flags.go
+4
-1
未找到文件。
cmd/geth/main.go
浏览文件 @
4a260dc1
...
@@ -157,6 +157,7 @@ func init() {
...
@@ -157,6 +157,7 @@ func init() {
attachCommand
,
attachCommand
,
javascriptCommand
,
javascriptCommand
,
// See misccmd.go:
// See misccmd.go:
makecacheCommand
,
makedagCommand
,
makedagCommand
,
versionCommand
,
versionCommand
,
bugCommand
,
bugCommand
,
...
...
cmd/geth/misccmd.go
浏览文件 @
4a260dc1
...
@@ -18,9 +18,7 @@ package main
...
@@ -18,9 +18,7 @@ package main
import
(
import
(
"fmt"
"fmt"
"io/ioutil"
"os"
"os"
"path/filepath"
"runtime"
"runtime"
"strconv"
"strconv"
"strings"
"strings"
...
@@ -33,14 +31,27 @@ import (
...
@@ -33,14 +31,27 @@ import (
)
)
var
(
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
{
makedagCommand
=
cli
.
Command
{
Action
:
utils
.
MigrateFlags
(
makedag
),
Action
:
utils
.
MigrateFlags
(
makedag
),
Name
:
"makedag"
,
Name
:
"makedag"
,
Usage
:
"Generate ethash DAG (for testing)"
,
Usage
:
"Generate ethash
mining
DAG (for testing)"
,
ArgsUsage
:
"<blockNum> <outputDir>"
,
ArgsUsage
:
"<blockNum> <outputDir>"
,
Category
:
"MISCELLANEOUS COMMANDS"
,
Category
:
"MISCELLANEOUS COMMANDS"
,
Description
:
`
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.
This command exists to support the system testing project.
Regular users do not need to execute it.
Regular users do not need to execute it.
...
@@ -65,33 +76,33 @@ The output of this command is supposed to be machine-readable.
...
@@ -65,33 +76,33 @@ The output of this command is supposed to be machine-readable.
}
}
)
)
// makecache generates an ethash verification cache into the provided folder.
func
makecache
(
ctx
*
cli
.
Context
)
error
{
args
:=
ctx
.
Args
()
if
len
(
args
)
!=
2
{
utils
.
Fatalf
(
`Usage: geth makecache <block number> <outputdir>`
)
}
block
,
err
:=
strconv
.
ParseUint
(
args
[
0
],
0
,
64
)
if
err
!=
nil
{
utils
.
Fatalf
(
"Invalid block number: %v"
,
err
)
}
ethash
.
MakeCache
(
block
,
args
[
1
])
return
nil
}
// makedag generates an ethash mining DAG into the provided folder.
func
makedag
(
ctx
*
cli
.
Context
)
error
{
func
makedag
(
ctx
*
cli
.
Context
)
error
{
args
:=
ctx
.
Args
()
args
:=
ctx
.
Args
()
wrongArgs
:=
func
()
{
if
len
(
args
)
!=
2
{
utils
.
Fatalf
(
`Usage: geth makedag <block number> <outputdir>`
)
utils
.
Fatalf
(
`Usage: geth makedag <block number> <outputdir>`
)
}
}
switch
{
block
,
err
:=
strconv
.
ParseUint
(
args
[
0
],
0
,
64
)
case
len
(
args
)
==
2
:
if
err
!=
nil
{
blockNum
,
err
:=
strconv
.
ParseUint
(
args
[
0
],
0
,
64
)
utils
.
Fatalf
(
"Invalid block number: %v"
,
err
)
dir
:=
args
[
1
]
if
err
!=
nil
{
wrongArgs
()
}
else
{
dir
=
filepath
.
Clean
(
dir
)
// seems to require a trailing slash
if
!
strings
.
HasSuffix
(
dir
,
"/"
)
{
dir
=
dir
+
"/"
}
_
,
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
)
}
default
:
wrongArgs
()
}
}
ethash
.
MakeDataset
(
block
,
args
[
1
])
return
nil
return
nil
}
}
...
...
cmd/utils/flags.go
浏览文件 @
4a260dc1
...
@@ -1093,7 +1093,10 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
...
@@ -1093,7 +1093,10 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
engine
:=
ethash
.
NewFaker
()
engine
:=
ethash
.
NewFaker
()
if
!
ctx
.
GlobalBool
(
FakePoWFlag
.
Name
)
{
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
))
config
,
_
,
err
:=
core
.
SetupGenesisBlock
(
chainDb
,
MakeGenesis
(
ctx
))
if
err
!=
nil
{
if
err
!=
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录