Skip to content

Commit f702e27

Browse files
committed
Fixed miner stopping / starting:wq
1 parent 0c5a747 commit f702e27

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

utils/cmd.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,17 @@ func StartMining(ethereum *eth.Ethereum) bool {
247247
addr := ethereum.KeyManager().Address()
248248

249249
go func() {
250-
miner = ethminer.NewDefaultMiner(addr, ethereum)
250+
if miner == nil {
251+
miner = ethminer.NewDefaultMiner(addr, ethereum)
252+
}
253+
251254
// Give it some time to connect with peers
252255
time.Sleep(3 * time.Second)
253256
for !ethereum.IsUpToDate() {
254257
time.Sleep(5 * time.Second)
255258
}
256259

257260
logger.Infoln("Miner started")
258-
miner := ethminer.NewDefaultMiner(addr, ethereum)
259261
miner.Start()
260262
}()
261263
RegisterInterrupt(func(os.Signal) {
@@ -269,10 +271,14 @@ func StartMining(ethereum *eth.Ethereum) bool {
269271
func StopMining(ethereum *eth.Ethereum) bool {
270272
if ethereum.Mining && miner != nil {
271273
miner.Stop()
274+
272275
logger.Infoln("Miner stopped")
276+
273277
ethereum.Mining = false
278+
274279
return true
275280
}
281+
276282
return false
277283
}
278284

0 commit comments

Comments
 (0)