Skip to content

Commit

Permalink
Fixed miner stopping / starting:wq
Browse files Browse the repository at this point in the history
  • Loading branch information
obscuren committed Jul 18, 2014
1 parent 0c5a747 commit f702e27
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions utils/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,17 @@ func StartMining(ethereum *eth.Ethereum) bool {
addr := ethereum.KeyManager().Address()

go func() {
miner = ethminer.NewDefaultMiner(addr, ethereum)
if miner == nil {
miner = ethminer.NewDefaultMiner(addr, ethereum)
}

// Give it some time to connect with peers
time.Sleep(3 * time.Second)
for !ethereum.IsUpToDate() {
time.Sleep(5 * time.Second)
}

logger.Infoln("Miner started")
miner := ethminer.NewDefaultMiner(addr, ethereum)
miner.Start()
}()
RegisterInterrupt(func(os.Signal) {
Expand All @@ -269,10 +271,14 @@ func StartMining(ethereum *eth.Ethereum) bool {
func StopMining(ethereum *eth.Ethereum) bool {
if ethereum.Mining && miner != nil {
miner.Stop()

logger.Infoln("Miner stopped")

ethereum.Mining = false

return true
}

return false
}

Expand Down

0 comments on commit f702e27

Please sign in to comment.