This commit is contained in:
obscuren
2015-03-03 17:56:36 +01:00
15 changed files with 169 additions and 209 deletions

View File

@ -5,6 +5,7 @@ import (
"math/big"
"sort"
"sync"
"time"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
@ -113,6 +114,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 {
@ -131,6 +134,8 @@ out:
agent.Stop()
}
break out
case <-timer.C:
minerlogger.Debugln("Hash rate:", self.HashRate(), "Khash")
}
}
@ -250,3 +255,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
}