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
a59cd946
Commit
a59cd946
authored
Feb 19, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add setMining RPC method
parent
605dd3a9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
0 deletions
+37
-0
message.go
rpc/message.go
+15
-0
packages.go
rpc/packages.go
+11
-0
xeth.go
xeth/xeth.go
+11
-0
No files found.
rpc/message.go
View file @
a59cd946
...
...
@@ -201,6 +201,21 @@ func (req *RpcRequest) ToGetCodeAtArgs() (*GetCodeAtArgs, error) {
return
args
,
nil
}
func
(
req
*
RpcRequest
)
ToBoolArgs
()
(
bool
,
error
)
{
if
len
(
req
.
Params
)
<
1
{
return
false
,
NewErrorResponse
(
ErrorArguments
)
}
var
args
bool
err
:=
json
.
Unmarshal
(
req
.
Params
[
0
],
&
args
)
if
err
!=
nil
{
return
false
,
NewErrorResponse
(
ErrorDecodeArgs
)
}
rpclogger
.
DebugDetailf
(
"%T %v"
,
args
,
args
)
return
args
,
nil
}
func
(
req
*
RpcRequest
)
ToCompileArgs
()
(
string
,
error
)
{
if
len
(
req
.
Params
)
<
1
{
return
""
,
NewErrorResponse
(
ErrorArguments
)
...
...
rpc/packages.go
View file @
a59cd946
...
...
@@ -267,6 +267,11 @@ func (p *EthereumApi) GetIsMining(reply *interface{}) error {
return
nil
}
func
(
p
*
EthereumApi
)
SetMining
(
shouldmine
bool
,
reply
*
interface
{})
error
{
*
reply
=
p
.
xeth
.
SetMining
(
shouldmine
)
return
nil
}
func
(
p
*
EthereumApi
)
BlockNumber
(
reply
*
interface
{})
error
{
*
reply
=
p
.
xeth
.
Backend
()
.
ChainManager
()
.
CurrentBlock
()
.
Number
()
return
nil
...
...
@@ -400,6 +405,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return
p
.
GetIsListening
(
reply
)
case
"eth_mining"
:
return
p
.
GetIsMining
(
reply
)
case
"eth_setMining"
:
args
,
err
:=
req
.
ToBoolArgs
()
if
err
!=
nil
{
return
err
}
return
p
.
SetMining
(
args
,
reply
)
case
"eth_peerCount"
:
return
p
.
GetPeerCount
(
reply
)
case
"eth_number"
:
...
...
xeth/xeth.go
View file @
a59cd946
...
...
@@ -102,6 +102,17 @@ func (self *XEth) IsMining() bool {
return
self
.
miner
.
Mining
()
}
func
(
self
*
XEth
)
SetMining
(
shouldmine
bool
)
bool
{
ismining
:=
self
.
miner
.
Mining
()
if
shouldmine
&&
!
ismining
{
self
.
miner
.
Start
()
}
if
ismining
&&
!
shouldmine
{
self
.
miner
.
Stop
()
}
return
self
.
miner
.
Mining
()
}
func
(
self
*
XEth
)
IsListening
()
bool
{
return
self
.
eth
.
IsListening
()
}
...
...
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