From 65cad14f9b27db396d036f47814d4843d947ac43 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 28 Feb 2015 23:09:49 +0100 Subject: Report debug hash rate --- miner/worker.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'miner/worker.go') 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 +} -- cgit