Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
372e1cad
Commit
372e1cad
authored
Mar 23, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup get/submitWork
getWork needs to return additional values
parent
8affdf96
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
12 deletions
+54
-12
api.go
rpc/api.go
+7
-11
args.go
rpc/args.go
+39
-0
miner_agest.go
rpc/miner_agest.go
+8
-1
No files found.
rpc/api.go
View file @
372e1cad
...
@@ -348,13 +348,14 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -348,13 +348,14 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
opts
:=
toFilterOptions
(
args
)
opts
:=
toFilterOptions
(
args
)
*
reply
=
NewLogsRes
(
p
.
xeth
()
.
AllLogs
(
opts
))
*
reply
=
NewLogsRes
(
p
.
xeth
()
.
AllLogs
(
opts
))
case
"eth_getWork"
:
case
"eth_getWork"
:
*
reply
=
p
.
getWork
()
p
.
xeth
()
.
SetMining
(
true
)
*
reply
=
p
.
agent
.
GetWork
()
.
Hex
()
case
"eth_submitWork"
:
case
"eth_submitWork"
:
// TODO what is the reply here?
args
:=
new
(
SubmitWorkArgs
)
// TODO what are the arguments?
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
p
.
agent
.
SetResult
(
0
,
common
.
Hash
{},
common
.
Hash
{})
return
err
}
return
NewNotImplementedError
(
req
.
Method
)
*
reply
=
p
.
agent
.
SetResult
(
args
.
Nonce
,
args
.
Digest
,
args
.
Header
)
case
"db_putString"
:
case
"db_putString"
:
args
:=
new
(
DbArgs
)
args
:=
new
(
DbArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
@@ -466,11 +467,6 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -466,11 +467,6 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return
nil
return
nil
}
}
func
(
p
*
EthereumApi
)
getWork
()
string
{
p
.
xeth
()
.
SetMining
(
true
)
return
p
.
agent
.
GetWork
()
.
Hex
()
}
func
toFilterOptions
(
options
*
BlockFilterArgs
)
*
core
.
FilterOptions
{
func
toFilterOptions
(
options
*
BlockFilterArgs
)
*
core
.
FilterOptions
{
var
opts
core
.
FilterOptions
var
opts
core
.
FilterOptions
...
...
rpc/args.go
View file @
372e1cad
...
@@ -686,3 +686,42 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -686,3 +686,42 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
return
nil
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
View file @
372e1cad
...
@@ -55,6 +55,8 @@ out:
...
@@ -55,6 +55,8 @@ out:
}
}
func
(
a
*
Agent
)
GetWork
()
common
.
Hash
{
func
(
a
*
Agent
)
GetWork
()
common
.
Hash
{
// TODO return HashNoNonce, DAGSeedHash, Difficulty
// XXX Wait here untill work != nil ?.
// XXX Wait here untill work != nil ?.
if
a
.
work
!=
nil
{
if
a
.
work
!=
nil
{
return
a
.
work
.
HashNoNonce
()
return
a
.
work
.
HashNoNonce
()
...
@@ -62,9 +64,14 @@ func (a *Agent) GetWork() common.Hash {
...
@@ -62,9 +64,14 @@ func (a *Agent) GetWork() common.Hash {
return
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
// Make sure the external miner was working on the right hash
if
a
.
currentWork
!=
nil
&&
a
.
work
!=
nil
&&
a
.
currentWork
.
Hash
()
==
a
.
work
.
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
()}
a
.
returnCh
<-
miner
.
Work
{
a
.
currentWork
.
Number
()
.
Uint64
(),
nonce
,
mixDigest
.
Bytes
(),
seedHash
.
Bytes
()}
return
true
}
}
return
false
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment