Commit f702e274 authored by obscuren's avatar obscuren

Fixed miner stopping / starting:wq

parent 0c5a747e
...@@ -247,7 +247,10 @@ func StartMining(ethereum *eth.Ethereum) bool { ...@@ -247,7 +247,10 @@ func StartMining(ethereum *eth.Ethereum) bool {
addr := ethereum.KeyManager().Address() addr := ethereum.KeyManager().Address()
go func() { go func() {
miner = ethminer.NewDefaultMiner(addr, ethereum) if miner == nil {
miner = ethminer.NewDefaultMiner(addr, ethereum)
}
// Give it some time to connect with peers // Give it some time to connect with peers
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
for !ethereum.IsUpToDate() { for !ethereum.IsUpToDate() {
...@@ -255,7 +258,6 @@ func StartMining(ethereum *eth.Ethereum) bool { ...@@ -255,7 +258,6 @@ func StartMining(ethereum *eth.Ethereum) bool {
} }
logger.Infoln("Miner started") logger.Infoln("Miner started")
miner := ethminer.NewDefaultMiner(addr, ethereum)
miner.Start() miner.Start()
}() }()
RegisterInterrupt(func(os.Signal) { RegisterInterrupt(func(os.Signal) {
...@@ -269,10 +271,14 @@ func StartMining(ethereum *eth.Ethereum) bool { ...@@ -269,10 +271,14 @@ func StartMining(ethereum *eth.Ethereum) bool {
func StopMining(ethereum *eth.Ethereum) bool { func StopMining(ethereum *eth.Ethereum) bool {
if ethereum.Mining && miner != nil { if ethereum.Mining && miner != nil {
miner.Stop() miner.Stop()
logger.Infoln("Miner stopped") logger.Infoln("Miner stopped")
ethereum.Mining = false ethereum.Mining = false
return true return true
} }
return false return false
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment