aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorMaran <maran.hidskes@gmail.com>2014-05-22 16:26:39 +0800
committerMaran <maran.hidskes@gmail.com>2014-05-22 16:26:39 +0800
commit8419ba0ec068779dd72dc67cce44a30f9ed2873f (patch)
tree6f7af48b7711aa9648e0a0b9d8b91918b3e07c41 /utils
parent93d79babc9fb1e1c66e6c108f1925212d394db06 (diff)
parent01b833146f3afa214586a1ffb710546a5e4cc90a (diff)
downloaddexon-8419ba0ec068779dd72dc67cce44a30f9ed2873f.tar.gz
dexon-8419ba0ec068779dd72dc67cce44a30f9ed2873f.tar.zst
dexon-8419ba0ec068779dd72dc67cce44a30f9ed2873f.zip
Fix merge conflicts
Diffstat (limited to 'utils')
-rw-r--r--utils/cmd.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/utils/cmd.go b/utils/cmd.go
index 28597194f..f8b7b5fe2 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,6 +33,10 @@ 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)
@@ -44,3 +50,27 @@ func DoMining(ethereum *eth.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
+}