Report debug hash rate

This commit is contained in:
obscuren 2015-02-28 23:09:49 +01:00
parent fdf939a6f9
commit 65cad14f9b
2 changed files with 15 additions and 6 deletions

View File

@ -52,10 +52,5 @@ func (self *Miner) Stop() {
} }
func (self *Miner) HashRate() int64 { func (self *Miner) HashRate() int64 {
var tot int64 return self.worker.HashRate()
for _, agent := range self.worker.agents {
tot += agent.Pow().GetHashrate()
}
return tot
} }

View File

@ -5,6 +5,7 @@ import (
"math/big" "math/big"
"sort" "sort"
"sync" "sync"
"time"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
@ -111,6 +112,8 @@ func (self *worker) register(agent Agent) {
func (self *worker) update() { func (self *worker) update() {
events := self.mux.Subscribe(core.ChainEvent{}, core.NewMinedBlockEvent{}) events := self.mux.Subscribe(core.ChainEvent{}, core.NewMinedBlockEvent{})
timer := time.NewTicker(2 * time.Second)
out: out:
for { for {
select { select {
@ -129,6 +132,8 @@ out:
agent.Stop() agent.Stop()
} }
break out 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 return nil
} }
func (self *worker) HashRate() int64 {
var tot int64
for _, agent := range self.agents {
tot += agent.Pow().GetHashrate()
}
return tot
}