WIP to expose hashrate to gui
This commit is contained in:
parent
44296c0b33
commit
2b9f16802d
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/ethereum/eth-go/ethchain"
|
"github.com/ethereum/eth-go/ethchain"
|
||||||
"github.com/ethereum/eth-go/ethdb"
|
"github.com/ethereum/eth-go/ethdb"
|
||||||
"github.com/ethereum/eth-go/ethlog"
|
"github.com/ethereum/eth-go/ethlog"
|
||||||
|
"github.com/ethereum/eth-go/ethminer"
|
||||||
"github.com/ethereum/eth-go/ethpub"
|
"github.com/ethereum/eth-go/ethpub"
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
"github.com/ethereum/eth-go/ethwire"
|
"github.com/ethereum/eth-go/ethwire"
|
||||||
@ -40,6 +41,8 @@ type Gui struct {
|
|||||||
Session string
|
Session string
|
||||||
clientIdentity *ethwire.SimpleClientIdentity
|
clientIdentity *ethwire.SimpleClientIdentity
|
||||||
config *ethutil.ConfigManager
|
config *ethutil.ConfigManager
|
||||||
|
|
||||||
|
miner *ethminer.Miner
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create GUI, but doesn't start it
|
// Create GUI, but doesn't start it
|
||||||
@ -124,6 +127,7 @@ func (gui *Gui) ToggleMining() {
|
|||||||
txt = "Start mining"
|
txt = "Start mining"
|
||||||
} else {
|
} else {
|
||||||
utils.StartMining(gui.eth)
|
utils.StartMining(gui.eth)
|
||||||
|
gui.miner = utils.GetMiner()
|
||||||
txt = "Stop mining"
|
txt = "Stop mining"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +350,10 @@ func (gui *Gui) update() {
|
|||||||
case <-peerChan:
|
case <-peerChan:
|
||||||
gui.setPeerInfo()
|
gui.setPeerInfo()
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
if gui.miner != nil {
|
||||||
|
pow := gui.miner.GetPow()
|
||||||
|
fmt.Println("HashRate from miner", pow.GetHashrate())
|
||||||
|
}
|
||||||
gui.setPeerInfo()
|
gui.setPeerInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,6 +236,10 @@ func StartRpc(ethereum *eth.Ethereum, RpcPort int) {
|
|||||||
|
|
||||||
var miner ethminer.Miner
|
var miner ethminer.Miner
|
||||||
|
|
||||||
|
func GetMiner() *ethminer.Miner {
|
||||||
|
return &miner
|
||||||
|
}
|
||||||
|
|
||||||
func StartMining(ethereum *eth.Ethereum) bool {
|
func StartMining(ethereum *eth.Ethereum) bool {
|
||||||
if !ethereum.Mining {
|
if !ethereum.Mining {
|
||||||
ethereum.Mining = true
|
ethereum.Mining = true
|
||||||
|
Loading…
Reference in New Issue
Block a user