diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-26 06:41:55 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-26 06:41:55 +0800 |
commit | 0d89c1d212e121b4904bf24b5332de9d4344334b (patch) | |
tree | b6499be349d9950ba083e211ebb787294fbf413c /utils/cmd.go | |
parent | 7f1a4c377c18055137909521d809251248b7b5af (diff) | |
parent | 818bc84591c490b29cb28ee1e4895c8f303a0af1 (diff) | |
download | go-tangerine-0d89c1d212e121b4904bf24b5332de9d4344334b.tar go-tangerine-0d89c1d212e121b4904bf24b5332de9d4344334b.tar.gz go-tangerine-0d89c1d212e121b4904bf24b5332de9d4344334b.tar.bz2 go-tangerine-0d89c1d212e121b4904bf24b5332de9d4344334b.tar.lz go-tangerine-0d89c1d212e121b4904bf24b5332de9d4344334b.tar.xz go-tangerine-0d89c1d212e121b4904bf24b5332de9d4344334b.tar.zst go-tangerine-0d89c1d212e121b4904bf24b5332de9d4344334b.zip |
Merge branch 'release/poc5-rc9'poc5-rc9
Diffstat (limited to 'utils/cmd.go')
-rw-r--r-- | utils/cmd.go | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/utils/cmd.go b/utils/cmd.go index f163575da..98005d7de 100644 --- a/utils/cmd.go +++ b/utils/cmd.go @@ -19,6 +19,8 @@ func DoRpc(ethereum *eth.Ethereum, RpcPort int) { } } +var miner ethminer.Miner + func DoMining(ethereum *eth.Ethereum) { // Set Mining status ethereum.Mining = true @@ -31,17 +33,37 @@ func DoMining(ethereum *eth.Ethereum) { addr := keyPair.Address() go func() { + ethutil.Config.Log.Infoln("Miner started") + + miner = ethminer.NewDefaultMiner(addr, ethereum) + // Give it some time to connect with peers time.Sleep(3 * time.Second) - /* - for ethereum.IsUpToDate() == false { - time.Sleep(5 * time.Second) - } - */ - ethutil.Config.Log.Infoln("Miner started") - - miner := ethminer.NewDefaultMiner(addr, ethereum) miner.Start() }() } + +func StopMining(ethereum *eth.Ethereum) bool { + if ethereum.Mining { + miner.Stop() + + ethutil.Config.Log.Infoln("Miner stopped") + + ethereum.Mining = false + + return true + } + + return false +} + +func StartMining(ethereum *eth.Ethereum) bool { + if !ethereum.Mining { + DoMining(ethereum) + + return true + } + + return false +} |