aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaran <maran.hidskes@gmail.com>2014-07-18 18:01:08 +0800
committerMaran <maran.hidskes@gmail.com>2014-07-18 18:01:08 +0800
commitdb8170def31e03ecb7086dd257d7c8fce084313f (patch)
treea12fe2de180f8e6a7f12d92832b1be52ad44ad9a
parent28a146d438b0c11820aef5d9551c6eff929acdec (diff)
downloadgo-tangerine-db8170def31e03ecb7086dd257d7c8fce084313f.tar
go-tangerine-db8170def31e03ecb7086dd257d7c8fce084313f.tar.gz
go-tangerine-db8170def31e03ecb7086dd257d7c8fce084313f.tar.bz2
go-tangerine-db8170def31e03ecb7086dd257d7c8fce084313f.tar.lz
go-tangerine-db8170def31e03ecb7086dd257d7c8fce084313f.tar.xz
go-tangerine-db8170def31e03ecb7086dd257d7c8fce084313f.tar.zst
go-tangerine-db8170def31e03ecb7086dd257d7c8fce084313f.zip
WIP to expose hashrate to gui
-rw-r--r--ethchain/dagger.go11
-rw-r--r--ethminer/miner.go4
2 files changed, 13 insertions, 2 deletions
diff --git a/ethchain/dagger.go b/ethchain/dagger.go
index 4dda21ff5..dccd2ff5b 100644
--- a/ethchain/dagger.go
+++ b/ethchain/dagger.go
@@ -16,10 +16,16 @@ var powlogger = ethlog.NewLogger("POW")
type PoW interface {
Search(block *Block, reactChan chan ethutil.React) []byte
Verify(hash []byte, diff *big.Int, nonce []byte) bool
+ GetHashrate() int64
}
type EasyPow struct {
- hash *big.Int
+ hash *big.Int
+ HashRate int64
+}
+
+func (pow *EasyPow) GetHashrate() int64 {
+ return pow.HashRate
}
func (pow *EasyPow) Search(block *Block, reactChan chan ethutil.React) []byte {
@@ -39,7 +45,8 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethutil.React) []byte {
if i%1234567 == 0 {
elapsed := time.Now().UnixNano() - start
hashes := ((float64(1e9) / float64(elapsed)) * float64(i)) / 1000
- powlogger.Infoln("Hashing @", int64(hashes), "khash")
+ pow.HashRate = int64(hashes)
+ powlogger.Infoln("Hashing @", int64(pow.HashRate), "khash")
}
sha := ethcrypto.Sha3Bin(big.NewInt(r.Int63()).Bytes())
diff --git a/ethminer/miner.go b/ethminer/miner.go
index 71d4b2428..f45615b62 100644
--- a/ethminer/miner.go
+++ b/ethminer/miner.go
@@ -24,6 +24,10 @@ type Miner struct {
quitChan chan bool
}
+func (self Miner) GetPow() *ethchain.PoW {
+ return &self.pow
+}
+
func NewDefaultMiner(coinbase []byte, ethereum ethchain.EthManager) Miner {
reactChan := make(chan ethutil.React, 1) // This is the channel that receives 'updates' when ever a new transaction or block comes in
powChan := make(chan []byte, 1) // This is the channel that receives valid sha hases for a given block