Skip to content

Commit

Permalink
Report debug hash rate
Browse files Browse the repository at this point in the history
  • Loading branch information
obscuren committed Feb 28, 2015
1 parent fdf939a commit 65cad14
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 1 addition & 6 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
14 changes: 14 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/big"
"sort"
"sync"
"time"

"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -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 {
Expand All @@ -129,6 +132,8 @@ out:
agent.Stop()
}
break out
case <-timer.C:
minerlogger.Debugln("Hash rate:", self.HashRate(), "Khash")
}
}

Expand Down Expand Up @@ -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
}

0 comments on commit 65cad14

Please sign in to comment.