aboutsummaryrefslogtreecommitdiffstats
path: root/miner
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-01 06:09:49 +0800
committerobscuren <geffobscura@gmail.com>2015-03-01 06:09:49 +0800
commit65cad14f9b27db396d036f47814d4843d947ac43 (patch)
tree89395b2035f38d9dd851c0d50a064387469355eb /miner
parentfdf939a6f9b5360d76415c7118969d92af2774f9 (diff)
downloaddexon-65cad14f9b27db396d036f47814d4843d947ac43.tar.gz
dexon-65cad14f9b27db396d036f47814d4843d947ac43.tar.zst
dexon-65cad14f9b27db396d036f47814d4843d947ac43.zip
Report debug hash rate
Diffstat (limited to 'miner')
-rw-r--r--miner/miner.go7
-rw-r--r--miner/worker.go14
2 files changed, 15 insertions, 6 deletions
diff --git a/miner/miner.go b/miner/miner.go
index 0cc2361c8..6b416be8e 100644
--- a/miner/miner.go
+++ b/miner/miner.go
@@ -52,10 +52,5 @@ func (self *Miner) Stop() {
}
func (self *Miner) HashRate() int64 {
- var tot int64
- for _, agent := range self.worker.agents {
- tot += agent.Pow().GetHashrate()
- }
-
- return tot
+ return self.worker.HashRate()
}
diff --git a/miner/worker.go b/miner/worker.go
index 4f0909302..afce68c35 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -5,6 +5,7 @@ import (
"math/big"
"sort"
"sync"
+ "time"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
@@ -111,6 +112,8 @@ func (self *worker) register(agent Agent) {
func (self *worker) update() {
events := self.mux.Subscribe(core.ChainEvent{}, core.NewMinedBlockEvent{})
+ timer := time.NewTicker(2 * time.Second)
+
out:
for {
select {
@@ -129,6 +132,8 @@ out:
agent.Stop()
}
break out
+ case <-timer.C:
+ minerlogger.Debugln("Hash rate:", self.HashRate(), "Khash")
}
}
@@ -244,3 +249,12 @@ func (self *worker) commitTransaction(tx *types.Transaction) error {
return nil
}
+
+func (self *worker) HashRate() int64 {
+ var tot int64
+ for _, agent := range self.agents {
+ tot += agent.Pow().GetHashrate()
+ }
+
+ return tot
+}