aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorMaran <maran.hidskes@gmail.com>2014-05-14 19:55:55 +0800
committerMaran <maran.hidskes@gmail.com>2014-05-14 19:55:55 +0800
commit2c7b625daaf062192db2fa604344f79c1bdbb232 (patch)
tree0aeca661324df1bf457d32ab8ab5c0c23fe1d504 /utils
parent9fce273ce97a8db091a0bf9d0b503a2ea7261f81 (diff)
downloaddexon-2c7b625daaf062192db2fa604344f79c1bdbb232.tar.gz
dexon-2c7b625daaf062192db2fa604344f79c1bdbb232.tar.zst
dexon-2c7b625daaf062192db2fa604344f79c1bdbb232.zip
Make sure we have a coinbase address to mine with
Diffstat (limited to 'utils')
-rw-r--r--utils/cmd.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/utils/cmd.go b/utils/cmd.go
index 5a100ca4f..66cfbeff9 100644
--- a/utils/cmd.go
+++ b/utils/cmd.go
@@ -26,6 +26,16 @@ func DoMining(ethereum *eth.Ethereum) {
// Set Mining status
ethereum.Mining = true
+ data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
+ if len(data) == 0 {
+ log.Println("No address found, can't start mining")
+ return
+ }
+
+ keyRing := ethutil.NewValueFromBytes(data)
+ addr := keyRing.Get(0).Bytes()
+ pair, _ := ethchain.NewKeyPairFromSec(ethutil.FromHex(hex.EncodeToString(addr)))
+
go func() {
// Give it some time to connect with peers
time.Sleep(3 * time.Second)
@@ -35,10 +45,6 @@ func DoMining(ethereum *eth.Ethereum) {
}
log.Println("Miner started")
- data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
- keyRing := ethutil.NewValueFromBytes(data)
- addr := keyRing.Get(0).Bytes()
- pair, _ := ethchain.NewKeyPairFromSec(ethutil.FromHex(hex.EncodeToString(addr)))
miner := ethminer.NewDefaultMiner(pair.Address(), ethereum)
miner.Start()
}()