Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
6ea7aae2
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,体验更适合开发者的 AI 搜索 >>
提交
6ea7aae2
编写于
2月 28, 2015
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed some methods from the JS REPL
上级
cc5c8a44
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
25 addition
and
54 deletion
+25
-54
cmd/ethereum/flags.go
cmd/ethereum/flags.go
+6
-0
cmd/ethereum/main.go
cmd/ethereum/main.go
+3
-0
cmd/ethereum/repl/repl.go
cmd/ethereum/repl/repl.go
+1
-0
core/genesis.go
core/genesis.go
+0
-2
javascript/javascript_runtime.go
javascript/javascript_runtime.go
+9
-49
javascript/js_lib.go
javascript/js_lib.go
+1
-1
state/dump.go
state/dump.go
+5
-2
未找到文件。
cmd/ethereum/flags.go
浏览文件 @
6ea7aae2
...
...
@@ -135,6 +135,12 @@ func Init() {
flag
.
Parse
()
// When the javascript console is started log to a file instead
// of stdout
if
StartJsConsole
{
LogFile
=
path
.
Join
(
Datadir
,
"ethereum.log"
)
}
var
err
error
if
NAT
,
err
=
nat
.
Parse
(
*
natstr
);
err
!=
nil
{
log
.
Fatalf
(
"-nat: %v"
,
err
)
...
...
cmd/ethereum/main.go
浏览文件 @
6ea7aae2
...
...
@@ -137,6 +137,9 @@ func main() {
utils
.
StartEthereum
(
ethereum
)
latestBlock
:=
ethereum
.
ChainManager
()
.
CurrentBlock
()
fmt
.
Printf
(
"Welcome to the FRONTIER
\n
"
)
if
StartJsConsole
{
InitJsConsole
(
ethereum
)
}
else
if
len
(
InputFile
)
>
0
{
...
...
cmd/ethereum/repl/repl.go
浏览文件 @
6ea7aae2
...
...
@@ -60,6 +60,7 @@ func (self *JSRepl) Start() {
if
!
self
.
running
{
self
.
running
=
true
repllogger
.
Infoln
(
"init JS Console"
)
reader
:=
bufio
.
NewReader
(
self
.
history
)
for
{
line
,
err
:=
reader
.
ReadString
(
'\n'
)
...
...
core/genesis.go
浏览文件 @
6ea7aae2
...
...
@@ -51,8 +51,6 @@ func GenesisBlock(db ethutil.Database) *types.Block {
statedb
.
Sync
()
genesis
.
Header
()
.
Root
=
statedb
.
Root
()
fmt
.
Printf
(
"+++ genesis +++
\n
Root: %x
\n
Hash: %x
\n
"
,
genesis
.
Header
()
.
Root
,
genesis
.
Hash
())
return
genesis
}
...
...
javascript/javascript_runtime.go
浏览文件 @
6ea7aae2
...
...
@@ -24,7 +24,7 @@ var jsrelogger = logger.NewLogger("JSRE")
type
JSRE
struct
{
ethereum
*
eth
.
Ethereum
Vm
*
otto
.
Otto
pipe
*
xeth
.
XEth
xeth
*
xeth
.
XEth
events
event
.
Subscription
...
...
@@ -67,7 +67,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
// We have to make sure that, whoever calls this, calls "Stop"
go
re
.
mainLoop
()
re
.
Bind
(
"eth"
,
&
JSEthereum
{
re
.
pipe
,
re
.
Vm
,
ethereum
})
re
.
Bind
(
"eth"
,
&
JSEthereum
{
re
.
xeth
,
re
.
Vm
,
ethereum
})
re
.
initStdFuncs
()
...
...
@@ -113,12 +113,10 @@ func (self *JSRE) mainLoop() {
func
(
self
*
JSRE
)
initStdFuncs
()
{
t
,
_
:=
self
.
Vm
.
Get
(
"eth"
)
eth
:=
t
.
Object
()
eth
.
Set
(
"watch"
,
self
.
watch
)
eth
.
Set
(
"addPeer"
,
self
.
addPeer
)
eth
.
Set
(
"connect"
,
self
.
connect
)
eth
.
Set
(
"require"
,
self
.
require
)
eth
.
Set
(
"stopMining"
,
self
.
stopMining
)
eth
.
Set
(
"startMining"
,
self
.
startMining
)
eth
.
Set
(
"execBlock"
,
self
.
execBlock
)
eth
.
Set
(
"dump"
,
self
.
dump
)
eth
.
Set
(
"export"
,
self
.
export
)
}
...
...
@@ -152,7 +150,8 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value {
}
statedb
:=
state
.
New
(
block
.
Root
(),
self
.
ethereum
.
Db
())
v
,
_
:=
self
.
Vm
.
ToValue
(
statedb
.
Dump
())
v
,
_
:=
self
.
Vm
.
ToValue
(
statedb
.
RawDump
())
return
v
}
...
...
@@ -167,36 +166,7 @@ func (self *JSRE) startMining(call otto.FunctionCall) otto.Value {
return
v
}
// eth.watch
func
(
self
*
JSRE
)
watch
(
call
otto
.
FunctionCall
)
otto
.
Value
{
addr
,
_
:=
call
.
Argument
(
0
)
.
ToString
()
var
storageAddr
string
var
cb
otto
.
Value
var
storageCallback
bool
if
len
(
call
.
ArgumentList
)
>
2
{
storageCallback
=
true
storageAddr
,
_
=
call
.
Argument
(
1
)
.
ToString
()
cb
=
call
.
Argument
(
2
)
}
else
{
cb
=
call
.
Argument
(
1
)
}
if
storageCallback
{
self
.
objectCb
[
addr
+
storageAddr
]
=
append
(
self
.
objectCb
[
addr
+
storageAddr
],
cb
)
// event := "storage:" + string(ethutil.Hex2Bytes(addr)) + ":" + string(ethutil.Hex2Bytes(storageAddr))
// self.ethereum.EventMux().Subscribe(event, self.changeChan)
}
else
{
self
.
objectCb
[
addr
]
=
append
(
self
.
objectCb
[
addr
],
cb
)
// event := "object:" + string(ethutil.Hex2Bytes(addr))
// self.ethereum.EventMux().Subscribe(event, self.changeChan)
}
return
otto
.
UndefinedValue
()
}
func
(
self
*
JSRE
)
addPeer
(
call
otto
.
FunctionCall
)
otto
.
Value
{
func
(
self
*
JSRE
)
connect
(
call
otto
.
FunctionCall
)
otto
.
Value
{
nodeURL
,
err
:=
call
.
Argument
(
0
)
.
ToString
()
if
err
!=
nil
{
return
otto
.
FalseValue
()
...
...
@@ -222,22 +192,12 @@ func (self *JSRE) require(call otto.FunctionCall) otto.Value {
return
t
}
func
(
self
*
JSRE
)
execBlock
(
call
otto
.
FunctionCall
)
otto
.
Value
{
hash
,
err
:=
call
.
Argument
(
0
)
.
ToString
()
if
err
!=
nil
{
return
otto
.
UndefinedValue
()
}
err
=
utils
.
BlockDo
(
self
.
ethereum
,
ethutil
.
Hex2Bytes
(
hash
))
if
err
!=
nil
{
fmt
.
Println
(
err
)
func
(
self
*
JSRE
)
export
(
call
otto
.
FunctionCall
)
otto
.
Value
{
if
len
(
call
.
ArgumentList
)
==
0
{
fmt
.
Println
(
"err: require file name"
)
return
otto
.
FalseValue
()
}
return
otto
.
TrueValue
()
}
func
(
self
*
JSRE
)
export
(
call
otto
.
FunctionCall
)
otto
.
Value
{
fn
,
err
:=
call
.
Argument
(
0
)
.
ToString
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
...
...
javascript/js_lib.go
浏览文件 @
6ea7aae2
...
...
@@ -16,7 +16,7 @@ function pp(object) {
str += " ]";
} else if(typeof(object) === "object") {
str += "{ ";
var last = Object.keys(object).
sort().
pop()
var last = Object.keys(object).pop()
for(var k in object) {
str += k + ": " + pp(object[k]);
...
...
state/dump.go
浏览文件 @
6ea7aae2
...
...
@@ -20,7 +20,7 @@ type World struct {
Accounts
map
[
string
]
Account
`json:"accounts"`
}
func
(
self
*
StateDB
)
Dump
()
[]
byte
{
func
(
self
*
StateDB
)
RawDump
()
World
{
world
:=
World
{
Root
:
ethutil
.
Bytes2Hex
(
self
.
trie
.
Root
()),
Accounts
:
make
(
map
[
string
]
Account
),
...
...
@@ -39,8 +39,11 @@ func (self *StateDB) Dump() []byte {
}
world
.
Accounts
[
ethutil
.
Bytes2Hex
(
it
.
Key
)]
=
account
}
return
world
}
json
,
err
:=
json
.
MarshalIndent
(
world
,
""
,
" "
)
func
(
self
*
StateDB
)
Dump
()
[]
byte
{
json
,
err
:=
json
.
MarshalIndent
(
self
.
RawDump
(),
""
,
" "
)
if
err
!=
nil
{
fmt
.
Println
(
"dump err"
,
err
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录