Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
372e1cad
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,发现更多精彩内容 >>
提交
372e1cad
编写于
3月 23, 2015
作者:
T
Taylor Gerring
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup get/submitWork
getWork needs to return additional values
上级
8affdf96
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
54 addition
and
12 deletion
+54
-12
rpc/api.go
rpc/api.go
+7
-11
rpc/args.go
rpc/args.go
+39
-0
rpc/miner_agest.go
rpc/miner_agest.go
+8
-1
未找到文件。
rpc/api.go
浏览文件 @
372e1cad
...
...
@@ -348,13 +348,14 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
opts
:=
toFilterOptions
(
args
)
*
reply
=
NewLogsRes
(
p
.
xeth
()
.
AllLogs
(
opts
))
case
"eth_getWork"
:
*
reply
=
p
.
getWork
()
p
.
xeth
()
.
SetMining
(
true
)
*
reply
=
p
.
agent
.
GetWork
()
.
Hex
()
case
"eth_submitWork"
:
// TODO what is the reply here?
// TODO what are the arguments?
p
.
agent
.
SetResult
(
0
,
common
.
Hash
{},
common
.
Hash
{})
return
NewNotImplementedError
(
req
.
Method
)
args
:=
new
(
SubmitWorkArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
return
err
}
*
reply
=
p
.
agent
.
SetResult
(
args
.
Nonce
,
args
.
Digest
,
args
.
Header
)
case
"db_putString"
:
args
:=
new
(
DbArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
@@ -466,11 +467,6 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return
nil
}
func
(
p
*
EthereumApi
)
getWork
()
string
{
p
.
xeth
()
.
SetMining
(
true
)
return
p
.
agent
.
GetWork
()
.
Hex
()
}
func
toFilterOptions
(
options
*
BlockFilterArgs
)
*
core
.
FilterOptions
{
var
opts
core
.
FilterOptions
...
...
rpc/args.go
浏览文件 @
372e1cad
...
...
@@ -686,3 +686,42 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
return
nil
}
type
SubmitWorkArgs
struct
{
Nonce
uint64
Header
common
.
Hash
Digest
common
.
Hash
}
func
(
args
*
SubmitWorkArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
var
obj
[]
interface
{}
if
err
=
json
.
Unmarshal
(
b
,
&
obj
);
err
!=
nil
{
return
NewDecodeParamError
(
err
.
Error
())
}
if
len
(
obj
)
<
3
{
return
NewInsufficientParamsError
(
len
(
obj
),
3
)
}
var
objstr
string
var
ok
bool
if
objstr
,
ok
=
obj
[
0
]
.
(
string
);
!
ok
{
return
NewDecodeParamError
(
"Nonce is not a string"
)
}
args
.
Nonce
=
common
.
BytesToNumber
(
common
.
Hex2Bytes
(
objstr
))
if
objstr
,
ok
=
obj
[
1
]
.
(
string
);
!
ok
{
return
NewDecodeParamError
(
"Header is not a string"
)
}
args
.
Header
=
common
.
HexToHash
(
objstr
)
if
objstr
,
ok
=
obj
[
2
]
.
(
string
);
!
ok
{
return
NewDecodeParamError
(
"Digest is not a string"
)
}
args
.
Digest
=
common
.
HexToHash
(
objstr
)
return
nil
}
rpc/miner_agest.go
浏览文件 @
372e1cad
...
...
@@ -55,6 +55,8 @@ out:
}
func
(
a
*
Agent
)
GetWork
()
common
.
Hash
{
// TODO return HashNoNonce, DAGSeedHash, Difficulty
// XXX Wait here untill work != nil ?.
if
a
.
work
!=
nil
{
return
a
.
work
.
HashNoNonce
()
...
...
@@ -62,9 +64,14 @@ func (a *Agent) GetWork() common.Hash {
return
common
.
Hash
{}
}
func
(
a
*
Agent
)
SetResult
(
nonce
uint64
,
mixDigest
,
seedHash
common
.
Hash
)
{
func
(
a
*
Agent
)
SetResult
(
nonce
uint64
,
mixDigest
,
seedHash
common
.
Hash
)
bool
{
// Return true or false, but does not indicate if the PoW was correct
// Make sure the external miner was working on the right hash
if
a
.
currentWork
!=
nil
&&
a
.
work
!=
nil
&&
a
.
currentWork
.
Hash
()
==
a
.
work
.
Hash
()
{
a
.
returnCh
<-
miner
.
Work
{
a
.
currentWork
.
Number
()
.
Uint64
(),
nonce
,
mixDigest
.
Bytes
(),
seedHash
.
Bytes
()}
return
true
}
return
false
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录