aboutsummaryrefslogtreecommitdiffstats
path: root/pow/ezp
diff options
context:
space:
mode:
Diffstat (limited to 'pow/ezp')
-rw-r--r--pow/ezp/pow.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index e4caa076a..5571e73cd 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -21,7 +21,7 @@ type EasyPow struct {
}
func New() *EasyPow {
- return &EasyPow{turbo: false}
+ return &EasyPow{turbo: true}
}
func (pow *EasyPow) GetHashrate() int64 {
@@ -36,26 +36,33 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
hash := block.HashNoNonce()
diff := block.Difficulty()
- i := int64(0)
+ //i := int64(0)
+ // TODO fix offset
+ i := rand.Int63()
+ starti := i
start := time.Now().UnixNano()
- t := time.Now()
+
+ // Make sure stop is empty
+empty:
+ for {
+ select {
+ case <-stop:
+ default:
+ break empty
+ }
+ }
for {
select {
case <-stop:
- powlogger.Infoln("Breaking from mining")
pow.HashRate = 0
return nil
default:
i++
- if time.Since(t) > (1 * time.Second) {
- elapsed := time.Now().UnixNano() - start
- hashes := ((float64(1e9) / float64(elapsed)) * float64(i)) / 1000
- pow.HashRate = int64(hashes)
-
- t = time.Now()
- }
+ elapsed := time.Now().UnixNano() - start
+ hashes := ((float64(1e9) / float64(elapsed)) * float64(i-starti)) / 1000
+ pow.HashRate = int64(hashes)
sha := crypto.Sha3(big.NewInt(r.Int63()).Bytes())
if verify(hash, diff, sha) {