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
82920138
Commit
82920138
authored
Aug 26, 2015
by
Gustav Simonsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rpc: return error code for eth_getWork when no work ready
parent
abce0995
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
4 deletions
+28
-4
remote_agent.go
miner/remote_agent.go
+5
-3
eth.go
rpc/api/eth.go
+6
-1
errors.go
rpc/shared/errors.go
+14
-0
types.go
rpc/shared/types.go
+3
-0
No files found.
miner/remote_agent.go
View file @
82920138
...
...
@@ -17,6 +17,7 @@
package
miner
import
(
"errors"
"math/big"
"sync"
"time"
...
...
@@ -90,7 +91,7 @@ func (a *RemoteAgent) GetHashRate() (tot int64) {
return
}
func
(
a
*
RemoteAgent
)
GetWork
()
[
3
]
string
{
func
(
a
*
RemoteAgent
)
GetWork
()
([
3
]
string
,
error
)
{
a
.
mu
.
Lock
()
defer
a
.
mu
.
Unlock
()
...
...
@@ -110,9 +111,10 @@ func (a *RemoteAgent) GetWork() [3]string {
res
[
2
]
=
common
.
BytesToHash
(
n
.
Bytes
())
.
Hex
()
a
.
work
[
block
.
HashNoNonce
()]
=
a
.
currentWork
return
res
,
nil
}
else
{
return
res
,
errors
.
New
(
"No work available yet, don't panic."
)
}
return
res
}
// Returns true or false, but does not indicate if the PoW was correct
...
...
rpc/api/eth.go
View file @
82920138
...
...
@@ -563,7 +563,12 @@ func (self *ethApi) GetLogs(req *shared.Request) (interface{}, error) {
func
(
self
*
ethApi
)
GetWork
(
req
*
shared
.
Request
)
(
interface
{},
error
)
{
self
.
xeth
.
SetMining
(
true
,
0
)
return
self
.
xeth
.
RemoteMining
()
.
GetWork
(),
nil
ret
,
err
:=
self
.
xeth
.
RemoteMining
()
.
GetWork
()
if
err
!=
nil
{
return
nil
,
shared
.
NewNotReadyError
(
"getWork"
)
}
else
{
return
ret
,
nil
}
}
func
(
self
*
ethApi
)
SubmitWork
(
req
*
shared
.
Request
)
(
interface
{},
error
)
{
...
...
rpc/shared/errors.go
View file @
82920138
...
...
@@ -64,6 +64,20 @@ func NewNotImplementedError(method string) *NotImplementedError {
}
}
type
NotReadyError
struct
{
Method
string
}
func
(
e
*
NotReadyError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"%s method not ready"
,
e
.
Method
)
}
func
NewNotReadyError
(
method
string
)
*
NotReadyError
{
return
&
NotReadyError
{
Method
:
method
,
}
}
type
DecodeParamError
struct
{
err
string
}
...
...
rpc/shared/types.go
View file @
82920138
...
...
@@ -94,6 +94,9 @@ func NewRpcResponse(id interface{}, jsonrpcver string, reply interface{}, err er
case
*
NotImplementedError
:
jsonerr
:=
&
ErrorObject
{
-
32601
,
err
.
Error
()}
response
=
&
ErrorResponse
{
Jsonrpc
:
jsonrpcver
,
Id
:
id
,
Error
:
jsonerr
}
case
*
NotReadyError
:
jsonerr
:=
&
ErrorObject
{
-
32000
,
err
.
Error
()}
response
=
&
ErrorResponse
{
Jsonrpc
:
jsonrpcver
,
Id
:
id
,
Error
:
jsonerr
}
case
*
DecodeParamError
,
*
InsufficientParamsError
,
*
ValidationError
,
*
InvalidTypeError
:
jsonerr
:=
&
ErrorObject
{
-
32602
,
err
.
Error
()}
response
=
&
ErrorResponse
{
Jsonrpc
:
jsonrpcver
,
Id
:
id
,
Error
:
jsonerr
}
...
...
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