aboutsummaryrefslogtreecommitdiff
path: root/eth/backend.go
diff options
context:
space:
mode:
Diffstat (limited to 'eth/backend.go')
-rw-r--r--eth/backend.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/eth/backend.go b/eth/backend.go
index b5f590e..12041de 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -409,6 +409,17 @@ func (s *Ethereum) SetEtherbase(etherbase common.Address) {
// is already running, this method adjust the number of threads allowed to use
// and updates the minimum price required by the transaction pool.
func (s *Ethereum) StartMining(threads int) error {
+ // Update the thread count within the consensus engine
+ type threaded interface {
+ SetThreads(threads int)
+ }
+ if th, ok := s.engine.(threaded); ok {
+ log.Info("Updated mining threads", "threads", threads)
+ if threads == 0 {
+ threads = -1 // Disable the miner from within
+ }
+ th.SetThreads(threads)
+ }
// If the miner was not running, initialize it
if !s.IsMining() {
// Propagate the initial price point to the transaction pool
@@ -509,10 +520,10 @@ func (s *Ethereum) Stop() error {
s.bloomIndexer.Close()
s.blockchain.Stop()
s.engine.Close()
- //s.protocolManager.Stop()
- //if s.lesServer != nil {
- // s.lesServer.Stop()
- //}
+ s.protocolManager.Stop()
+ if s.lesServer != nil {
+ s.lesServer.Stop()
+ }
s.txPool.Stop()
s.miner.Stop()
s.eventMux.Stop()