diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-04 00:56:36 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-04 00:56:36 +0800 |
commit | 40ff3cac3943ee672d818776fdd8235fc6684dca (patch) | |
tree | e32f82689b0c669d61688470af5e92c2eda44d34 /miner | |
parent | 53b5a45856c5d4c307dc55b4ae1b46efd9471142 (diff) | |
parent | 6e50a1e9f59532671eaa2bb2f2081a67f659bd0d (diff) | |
download | dexon-40ff3cac3943ee672d818776fdd8235fc6684dca.tar.gz dexon-40ff3cac3943ee672d818776fdd8235fc6684dca.tar.zst dexon-40ff3cac3943ee672d818776fdd8235fc6684dca.zip |
merge
Diffstat (limited to 'miner')
-rw-r--r-- | miner/miner.go | 7 | ||||
-rw-r--r-- | miner/worker.go | 14 |
2 files changed, 15 insertions, 6 deletions
diff --git a/miner/miner.go b/miner/miner.go index f207948a5..b60422a3a 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -55,10 +55,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 fe80b63ee..774ef9a7e 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" @@ -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 +} |