Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
01b83314
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,发现更多精彩内容 >>
提交
01b83314
编写于
5月 22, 2014
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added mining stop and start
上级
b902de20
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
9 deletion
+44
-9
ethereum/javascript_runtime.go
ethereum/javascript_runtime.go
+14
-1
utils/cmd.go
utils/cmd.go
+30
-8
未找到文件。
ethereum/javascript_runtime.go
浏览文件 @
01b83314
...
...
@@ -6,6 +6,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/obscuren/otto"
"io/ioutil"
"os"
...
...
@@ -116,14 +117,26 @@ func (self *JSRE) initStdFuncs() {
eth
.
Set
(
"watch"
,
self
.
watch
)
eth
.
Set
(
"addPeer"
,
self
.
addPeer
)
eth
.
Set
(
"require"
,
self
.
require
)
eth
.
Set
(
"stopMining"
,
self
.
stopMining
)
eth
.
Set
(
"startMining"
,
self
.
startMining
)
}
/*
* The following methods are natively implemented javascript functions
*/
func
(
self
*
JSRE
)
stopMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
v
,
_
:=
self
.
vm
.
ToValue
(
utils
.
StopMining
(
self
.
ethereum
))
return
v
}
func
(
self
*
JSRE
)
startMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
v
,
_
:=
self
.
vm
.
ToValue
(
utils
.
StartMining
(
self
.
ethereum
))
return
v
}
// eth.watch
func
(
self
JSRE
)
watch
(
call
otto
.
FunctionCall
)
otto
.
Value
{
func
(
self
*
JSRE
)
watch
(
call
otto
.
FunctionCall
)
otto
.
Value
{
addr
,
_
:=
call
.
Argument
(
0
)
.
ToString
()
var
storageAddr
string
var
cb
otto
.
Value
...
...
utils/cmd.go
浏览文件 @
01b83314
...
...
@@ -19,6 +19,8 @@ func DoRpc(ethereum *eth.Ethereum, RpcPort int) {
}
}
var
miner
ethminer
.
Miner
func
DoMining
(
ethereum
*
eth
.
Ethereum
)
{
// Set Mining status
ethereum
.
Mining
=
true
...
...
@@ -31,17 +33,37 @@ func DoMining(ethereum *eth.Ethereum) {
addr
:=
keyPair
.
Address
()
go
func
()
{
ethutil
.
Config
.
Log
.
Infoln
(
"Miner started"
)
miner
=
ethminer
.
NewDefaultMiner
(
addr
,
ethereum
)
// Give it some time to connect with peers
time
.
Sleep
(
3
*
time
.
Second
)
/*
for ethereum.IsUpToDate() == false {
time.Sleep(5 * time.Second)
}
*/
ethutil
.
Config
.
Log
.
Infoln
(
"Miner started"
)
miner
:=
ethminer
.
NewDefaultMiner
(
addr
,
ethereum
)
miner
.
Start
()
}()
}
func
StopMining
(
ethereum
*
eth
.
Ethereum
)
bool
{
if
ethereum
.
Mining
{
miner
.
Stop
()
ethutil
.
Config
.
Log
.
Infoln
(
"Miner stopped"
)
ethereum
.
Mining
=
false
return
true
}
return
false
}
func
StartMining
(
ethereum
*
eth
.
Ethereum
)
bool
{
if
!
ethereum
.
Mining
{
DoMining
(
ethereum
)
return
true
}
return
false
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录