aboutsummaryrefslogtreecommitdiffstats
path: root/eth/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'eth/api.go')
-rw-r--r--eth/api.go31
1 files changed, 19 insertions, 12 deletions
diff --git a/eth/api.go b/eth/api.go
index 041ccd397..0decd57ca 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -103,7 +103,7 @@ func (api *PublicMinerAPI) SubmitWork(nonce types.BlockNonce, solution, digest c
// result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty
func (api *PublicMinerAPI) GetWork() ([3]string, error) {
if !api.e.IsMining() {
- if err := api.e.StartMining(); err != nil {
+ if err := api.e.StartMining(false); err != nil {
return [3]string{}, err
}
}
@@ -139,26 +139,33 @@ func NewPrivateMinerAPI(e *Ethereum) *PrivateMinerAPI {
// threads allowed to use.
func (api *PrivateMinerAPI) Start(threads *int) error {
// Set the number of threads if the seal engine supports it
- if threads != nil {
- type threaded interface {
- SetThreads(threads int)
- }
- if th, ok := api.e.engine.(threaded); ok {
- log.Info("Updated mining threads", "threads", *threads)
- th.SetThreads(*threads)
- } else {
- log.Warn("Current seal engine isn't threaded")
- }
+ if threads == nil {
+ threads = new(int)
+ } else if *threads == 0 {
+ *threads = -1 // Disable the miner from within
+ }
+ type threaded interface {
+ SetThreads(threads int)
+ }
+ if th, ok := api.e.engine.(threaded); ok {
+ log.Info("Updated mining threads", "threads", *threads)
+ th.SetThreads(*threads)
}
// Start the miner and return
if !api.e.IsMining() {
- return api.e.StartMining()
+ return api.e.StartMining(true)
}
return nil
}
// Stop the miner
func (api *PrivateMinerAPI) Stop() bool {
+ type threaded interface {
+ SetThreads(threads int)
+ }
+ if th, ok := api.e.engine.(threaded); ok {
+ th.SetThreads(-1)
+ }
api.e.StopMining()
return true
}