good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
dda5af0e
Commit
dda5af0e
authored
Feb 9, 2016
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
eth, miner: move the public miner api into eth to access etherbase
parent
8b5b635d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
eth/api.go
+52
-0
52 additions, 0 deletions
eth/api.go
eth/backend.go
+1
-1
1 addition, 1 deletion
eth/backend.go
miner/api.go
+0
-75
0 additions, 75 deletions
miner/api.go
with
53 additions
and
76 deletions
eth/api.go
+
52
−
0
View file @
dda5af0e
...
...
@@ -169,6 +169,58 @@ func (s *PublicEthereumAPI) Syncing() (interface{}, error) {
return
false
,
nil
}
// PublicMinerAPI provides an API to control the miner.
// It offers only methods that operate on data that pose no security risk when it is publicly accessible.
type
PublicMinerAPI
struct
{
e
*
Ethereum
agent
*
miner
.
RemoteAgent
}
// NewPublicMinerAPI create a new PublicMinerAPI instance.
func
NewPublicMinerAPI
(
e
*
Ethereum
)
*
PublicMinerAPI
{
agent
:=
miner
.
NewRemoteAgent
()
e
.
Miner
()
.
Register
(
agent
)
return
&
PublicMinerAPI
{
e
,
agent
}
}
// Mining returns an indication if this node is currently mining.
func
(
s
*
PublicMinerAPI
)
Mining
()
bool
{
return
s
.
e
.
IsMining
()
}
// SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was
// accepted. Note, this is not an indication if the provided work was valid!
func
(
s
*
PublicMinerAPI
)
SubmitWork
(
nonce
rpc
.
HexNumber
,
solution
,
digest
common
.
Hash
)
bool
{
return
s
.
agent
.
SubmitWork
(
nonce
.
Uint64
(),
digest
,
solution
)
}
// GetWork returns a work package for external miner. The work package consists of 3 strings
// result[0], 32 bytes hex encoded current block header pow-hash
// result[1], 32 bytes hex encoded seed hash used for DAG
// result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty
func
(
s
*
PublicMinerAPI
)
GetWork
()
([]
string
,
error
)
{
if
!
s
.
e
.
IsMining
()
{
if
err
:=
s
.
e
.
StartMining
(
0
,
""
);
err
!=
nil
{
return
nil
,
err
}
}
if
work
,
err
:=
s
.
agent
.
GetWork
();
err
==
nil
{
return
work
[
:
],
nil
}
else
{
glog
.
Infof
(
"%v
\n
"
,
err
)
}
return
nil
,
fmt
.
Errorf
(
"mining not ready"
)
}
// SubmitHashrate can be used for remote miners to submit their hash rate. This enables the node to report the combined
// hash rate of all miners which submit work through this node. It accepts the miner hash rate and an identifier which
// must be unique between nodes.
func
(
s
*
PublicMinerAPI
)
SubmitHashrate
(
hashrate
rpc
.
HexNumber
,
id
common
.
Hash
)
bool
{
s
.
agent
.
SubmitHashrate
(
id
,
hashrate
.
Uint64
())
return
true
}
// PrivateMinerAPI provides private RPC methods to control the miner.
// These methods can be abused by external users and must be considered insecure for use by untrusted users.
type
PrivateMinerAPI
struct
{
...
...
This diff is collapsed.
Click to expand it.
eth/backend.go
+
1
−
1
View file @
dda5af0e
...
...
@@ -274,7 +274,7 @@ func (s *Ethereum) APIs() []rpc.API {
},
{
Namespace
:
"eth"
,
Version
:
"1.0"
,
Service
:
miner
.
NewPublicMinerAPI
(
s
.
Miner
()
),
Service
:
NewPublicMinerAPI
(
s
),
Public
:
true
,
},
{
Namespace
:
"eth"
,
...
...
This diff is collapsed.
Click to expand it.
miner/api.go
deleted
100644 → 0
+
0
−
75
View file @
8b5b635d
// Copyright 2015 The go-ethereum Authors
// This file is part of go-ethereum.
//
// go-ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
package
miner
import
(
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rpc"
)
// PublicMinerAPI provides an API to control the miner.
// It offers only methods that operate on data that pose no security risk when it is publicly accessible.
type
PublicMinerAPI
struct
{
miner
*
Miner
agent
*
RemoteAgent
}
// NewPublicMinerAPI create a new PublicMinerAPI instance.
func
NewPublicMinerAPI
(
miner
*
Miner
)
*
PublicMinerAPI
{
agent
:=
NewRemoteAgent
()
miner
.
Register
(
agent
)
return
&
PublicMinerAPI
{
miner
,
agent
}
}
// Mining returns an indication if this node is currently mining.
func
(
s
*
PublicMinerAPI
)
Mining
()
bool
{
return
s
.
miner
.
Mining
()
}
// SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was
// accepted. Note, this is not an indication if the provided work was valid!
func
(
s
*
PublicMinerAPI
)
SubmitWork
(
nonce
rpc
.
HexNumber
,
solution
,
digest
common
.
Hash
)
bool
{
return
s
.
agent
.
SubmitWork
(
nonce
.
Uint64
(),
digest
,
solution
)
}
// GetWork returns a work package for external miner. The work package consists of 3 strings
// result[0], 32 bytes hex encoded current block header pow-hash
// result[1], 32 bytes hex encoded seed hash used for DAG
// result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty
func
(
s
*
PublicMinerAPI
)
GetWork
()
([]
string
,
error
)
{
if
!
s
.
Mining
()
{
s
.
miner
.
Start
(
s
.
miner
.
coinbase
,
0
)
}
if
work
,
err
:=
s
.
agent
.
GetWork
();
err
==
nil
{
return
work
[
:
],
nil
}
else
{
glog
.
Infof
(
"%v
\n
"
,
err
)
}
return
nil
,
fmt
.
Errorf
(
"mining not ready"
)
}
// SubmitHashrate can be used for remote miners to submit their hash rate. This enables the node to report the combined
// hash rate of all miners which submit work through this node. It accepts the miner hash rate and an identifier which
// must be unique between nodes.
func
(
s
*
PublicMinerAPI
)
SubmitHashrate
(
hashrate
rpc
.
HexNumber
,
id
common
.
Hash
)
bool
{
s
.
agent
.
SubmitHashrate
(
id
,
hashrate
.
Uint64
())
return
true
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment