Skip to content

Commit 2b9f168

Browse files
author
Maran
committed
WIP to expose hashrate to gui
1 parent 44296c0 commit 2b9f168

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

ethereal/gui.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/ethereum/eth-go/ethchain"
88
"github.com/ethereum/eth-go/ethdb"
99
"github.com/ethereum/eth-go/ethlog"
10+
"github.com/ethereum/eth-go/ethminer"
1011
"github.com/ethereum/eth-go/ethpub"
1112
"github.com/ethereum/eth-go/ethutil"
1213
"github.com/ethereum/eth-go/ethwire"
@@ -40,6 +41,8 @@ type Gui struct {
4041
Session string
4142
clientIdentity *ethwire.SimpleClientIdentity
4243
config *ethutil.ConfigManager
44+
45+
miner *ethminer.Miner
4346
}
4447

4548
// Create GUI, but doesn't start it
@@ -124,6 +127,7 @@ func (gui *Gui) ToggleMining() {
124127
txt = "Start mining"
125128
} else {
126129
utils.StartMining(gui.eth)
130+
gui.miner = utils.GetMiner()
127131
txt = "Stop mining"
128132
}
129133

@@ -346,6 +350,10 @@ func (gui *Gui) update() {
346350
case <-peerChan:
347351
gui.setPeerInfo()
348352
case <-ticker.C:
353+
if gui.miner != nil {
354+
pow := gui.miner.GetPow()
355+
fmt.Println("HashRate from miner", pow.GetHashrate())
356+
}
349357
gui.setPeerInfo()
350358
}
351359
}

utils/cmd.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ func StartRpc(ethereum *eth.Ethereum, RpcPort int) {
236236

237237
var miner ethminer.Miner
238238

239+
func GetMiner() *ethminer.Miner {
240+
return &miner
241+
}
242+
239243
func StartMining(ethereum *eth.Ethereum) bool {
240244
if !ethereum.Mining {
241245
ethereum.Mining = true

0 commit comments

Comments
 (0)