Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
934f587b
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,发现更多精彩内容 >>
提交
934f587b
编写于
4月 12, 2016
作者:
J
Jeffrey Wilcke
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2431 from bas-vk/js-preload
cmd/geth: add JS preload parameter
上级
e456451a
3c532959
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
0 deletion
+38
-0
cmd/geth/js.go
cmd/geth/js.go
+18
-0
cmd/geth/main.go
cmd/geth/main.go
+15
-0
cmd/geth/usage.go
cmd/geth/usage.go
+1
-0
cmd/utils/flags.go
cmd/utils/flags.go
+4
-0
未找到文件。
cmd/geth/js.go
浏览文件 @
934f587b
...
...
@@ -27,6 +27,7 @@ import (
"sort"
"strings"
"github.com/codegangsta/cli"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/registrar"
...
...
@@ -331,6 +332,23 @@ func (self *jsre) UnlockAccount(addr []byte) bool {
}
}
// preloadJSFiles loads JS files that the user has specified with ctx.PreLoadJSFlag into
// the JSRE. If not all files could be loaded it will return an error describing the error.
func
(
self
*
jsre
)
preloadJSFiles
(
ctx
*
cli
.
Context
)
error
{
if
ctx
.
GlobalString
(
utils
.
PreLoadJSFlag
.
Name
)
!=
""
{
assetPath
:=
ctx
.
GlobalString
(
utils
.
JSpathFlag
.
Name
)
jsFiles
:=
strings
.
Split
(
ctx
.
GlobalString
(
utils
.
PreLoadJSFlag
.
Name
),
","
)
for
_
,
file
:=
range
jsFiles
{
filename
:=
common
.
AbsolutePath
(
assetPath
,
strings
.
TrimSpace
(
file
))
if
err
:=
self
.
re
.
Exec
(
filename
);
err
!=
nil
{
return
fmt
.
Errorf
(
"%s: %v"
,
file
,
err
)
}
}
}
return
nil
}
// exec executes the JS file with the given filename and stops the JSRE
func
(
self
*
jsre
)
exec
(
filename
string
)
error
{
if
err
:=
self
.
re
.
Exec
(
filename
);
err
!=
nil
{
self
.
re
.
Stop
(
false
)
...
...
cmd/geth/main.go
浏览文件 @
934f587b
...
...
@@ -331,6 +331,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils
.
IPCApiFlag
,
utils
.
IPCPathFlag
,
utils
.
ExecFlag
,
utils
.
PreLoadJSFlag
,
utils
.
WhisperEnabledFlag
,
utils
.
DevModeFlag
,
utils
.
TestNetFlag
,
...
...
@@ -427,6 +428,13 @@ func attach(ctx *cli.Context) {
true
,
)
// preload user defined JS files into the console
err
=
repl
.
preloadJSFiles
(
ctx
)
if
err
!=
nil
{
utils
.
Fatalf
(
"unable to preload JS file %v"
,
err
)
}
// in case the exec flag holds a JS statement execute it and return
if
ctx
.
GlobalString
(
utils
.
ExecFlag
.
Name
)
!=
""
{
repl
.
batch
(
ctx
.
GlobalString
(
utils
.
ExecFlag
.
Name
))
}
else
{
...
...
@@ -477,6 +485,13 @@ func console(ctx *cli.Context) {
ctx
.
GlobalString
(
utils
.
RPCCORSDomainFlag
.
Name
),
client
,
true
)
// preload user defined JS files into the console
err
=
repl
.
preloadJSFiles
(
ctx
)
if
err
!=
nil
{
utils
.
Fatalf
(
"unable to preload JS file %v"
,
err
)
}
// in case the exec flag holds a JS statement execute it and return
if
script
:=
ctx
.
GlobalString
(
utils
.
ExecFlag
.
Name
);
script
!=
""
{
repl
.
batch
(
script
)
}
else
{
...
...
cmd/geth/usage.go
浏览文件 @
934f587b
...
...
@@ -101,6 +101,7 @@ var AppHelpFlagGroups = []flagGroup{
utils
.
RPCCORSDomainFlag
,
utils
.
JSpathFlag
,
utils
.
ExecFlag
,
utils
.
PreLoadJSFlag
,
},
},
{
...
...
cmd/utils/flags.go
浏览文件 @
934f587b
...
...
@@ -296,6 +296,10 @@ var (
Name
:
"exec"
,
Usage
:
"Execute JavaScript statement (only in combination with console/attach)"
,
}
PreLoadJSFlag
=
cli
.
StringFlag
{
Name
:
"preload"
,
Usage
:
"Comma separated list of JavaScript files to preload into the console"
,
}
// Network Settings
MaxPeersFlag
=
cli
.
IntFlag
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录