diff options
author | Maran <maran.hidskes@gmail.com> | 2014-05-14 19:26:15 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-05-14 19:26:15 +0800 |
commit | 2012e0c67abd8e3012a3eb1fae2e282e2a442d01 (patch) | |
tree | f65f5fe10c902fe4aa38da3efd0454c0f96b4f07 /utils | |
parent | e8147cf7c6f508910698e6743ad347c78010ffe3 (diff) | |
download | go-tangerine-2012e0c67abd8e3012a3eb1fae2e282e2a442d01.tar go-tangerine-2012e0c67abd8e3012a3eb1fae2e282e2a442d01.tar.gz go-tangerine-2012e0c67abd8e3012a3eb1fae2e282e2a442d01.tar.bz2 go-tangerine-2012e0c67abd8e3012a3eb1fae2e282e2a442d01.tar.lz go-tangerine-2012e0c67abd8e3012a3eb1fae2e282e2a442d01.tar.xz go-tangerine-2012e0c67abd8e3012a3eb1fae2e282e2a442d01.tar.zst go-tangerine-2012e0c67abd8e3012a3eb1fae2e282e2a442d01.zip |
Rewritten a check to only start mining once we are caught up with all peers
Diffstat (limited to 'utils')
-rw-r--r-- | utils/cmd.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/utils/cmd.go b/utils/cmd.go index a99fd9eed..44924ce91 100644 --- a/utils/cmd.go +++ b/utils/cmd.go @@ -8,24 +8,27 @@ import ( _ "github.com/ethereum/eth-go/ethrpc" "github.com/ethereum/eth-go/ethutil" "log" + "time" ) func DoMining(ethereum *eth.Ethereum) { // Set Mining status ethereum.Mining = true - log.Println("Miner started") - - // Fake block mining. It broadcasts a new block every 5 seconds go func() { + // Give it some time to connect with peers + time.Sleep(3 * time.Second) + + for ethereum.IsUpToDate() == false { + time.Sleep(5 * time.Second) + } + 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() - }() } |