From f111fc060884d69fbe46066b9ccae4c9aa5da890 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Mon, 15 Dec 2014 11:37:23 +0100
Subject: WIP

---
 pow/ezp/pow.go | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index cdf89950f..b4f863cb6 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -59,7 +59,7 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
 			}
 
 			sha := crypto.Sha3(big.NewInt(r.Int63()).Bytes())
-			if pow.verify(hash, diff, sha) {
+			if verify(hash, diff, sha) {
 				return sha
 			}
 		}
@@ -72,7 +72,11 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
 	return nil
 }
 
-func (pow *EasyPow) verify(hash []byte, diff *big.Int, nonce []byte) bool {
+func (pow *EasyPow) Verify(block pow.Block) bool {
+	return Verify(block)
+}
+
+func verify(hash []byte, diff *big.Int, nonce []byte) bool {
 	sha := sha3.NewKeccak256()
 
 	d := append(hash, nonce...)
@@ -84,6 +88,6 @@ func (pow *EasyPow) verify(hash []byte, diff *big.Int, nonce []byte) bool {
 	return res.Cmp(verification) <= 0
 }
 
-func (pow *EasyPow) Verify(block pow.Block) bool {
-	return pow.verify(block.HashNoNonce(), block.Diff(), block.N())
+func Verify(block pow.Block) bool {
+	return verify(block.HashNoNonce(), block.Diff(), block.N())
 }
-- 
cgit v1.2.3


From 4cd79d8ddd7608d60344b13fe4bda7315429d1d9 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Tue, 23 Dec 2014 13:48:44 +0100
Subject: Refactored block & Transaction

* Includes new rlp decoder
---
 pow/ezp/pow.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index f669f8aa4..f9f27326f 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -35,7 +35,7 @@ func (pow *EasyPow) Turbo(on bool) {
 func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
 	r := rand.New(rand.NewSource(time.Now().UnixNano()))
 	hash := block.HashNoNonce()
-	diff := block.Diff()
+	diff := block.Difficulty()
 	i := int64(0)
 	start := time.Now().UnixNano()
 	t := time.Now()
@@ -89,5 +89,5 @@ func verify(hash []byte, diff *big.Int, nonce []byte) bool {
 }
 
 func Verify(block pow.Block) bool {
-	return verify(block.HashNoNonce(), block.Diff(), block.N())
+	return verify(block.HashNoNonce(), block.Difficulty(), block.N())
 }
-- 
cgit v1.2.3


From c9985bf563888d5f346408d2ff174167e8b65880 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Mon, 5 Jan 2015 19:53:53 +0100
Subject: Fixed peer window. Minor tweaks and fixes

---
 pow/ezp/pow.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index f9f27326f..8c164798a 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -21,7 +21,7 @@ type EasyPow struct {
 }
 
 func New() *EasyPow {
-	return &EasyPow{turbo: true}
+	return &EasyPow{turbo: false}
 }
 
 func (pow *EasyPow) GetHashrate() int64 {
-- 
cgit v1.2.3


From 6eaa404187953777e8dc866e4e3db089e4ad0501 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Thu, 22 Jan 2015 00:25:00 +0100
Subject: Moved sha3 from `obscuren`

---
 pow/ezp/pow.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index 8c164798a..5abe6950e 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -6,10 +6,10 @@ import (
 	"time"
 
 	"github.com/ethereum/go-ethereum/crypto"
+	"github.com/ethereum/go-ethereum/crypto/sha3"
 	"github.com/ethereum/go-ethereum/ethutil"
 	"github.com/ethereum/go-ethereum/logger"
 	"github.com/ethereum/go-ethereum/pow"
-	"github.com/obscuren/sha3"
 )
 
 var powlogger = logger.NewLogger("POW")
-- 
cgit v1.2.3


From b1870631a4829e075eae77064973ef94aa2166b3 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Wed, 4 Feb 2015 05:52:59 -0800
Subject: WIP miner

---
 pow/ezp/pow.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index 5abe6950e..64d3230c9 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -53,7 +53,7 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
 				elapsed := time.Now().UnixNano() - start
 				hashes := ((float64(1e9) / float64(elapsed)) * float64(i)) / 1000
 				pow.HashRate = int64(hashes)
-				powlogger.Infoln("Hashing @", pow.HashRate, "khash")
+				//powlogger.Infoln("Hashing @", pow.HashRate, "khash")
 
 				t = time.Now()
 			}
-- 
cgit v1.2.3


From a1b4547a53c4c738e435c1968c1e606935912e47 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Wed, 4 Feb 2015 18:26:23 -0800
Subject: set uncles regardless of empty uncle list. Fixes invalid blocks being
 mined

---
 pow/ezp/pow.go | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index 64d3230c9..2791c4b0b 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -1,6 +1,7 @@
 package ezp
 
 import (
+	"fmt"
 	"math/big"
 	"math/rand"
 	"time"
@@ -53,13 +54,13 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
 				elapsed := time.Now().UnixNano() - start
 				hashes := ((float64(1e9) / float64(elapsed)) * float64(i)) / 1000
 				pow.HashRate = int64(hashes)
-				//powlogger.Infoln("Hashing @", pow.HashRate, "khash")
 
 				t = time.Now()
 			}
 
 			sha := crypto.Sha3(big.NewInt(r.Int63()).Bytes())
 			if verify(hash, diff, sha) {
+				fmt.Printf("HASH: %x\nDIFF %v\nSHA %x\n", hash, diff, sha)
 				return sha
 			}
 		}
@@ -83,7 +84,7 @@ func verify(hash []byte, diff *big.Int, nonce []byte) bool {
 	sha.Write(d)
 
 	verification := new(big.Int).Div(ethutil.BigPow(2, 256), diff)
-	res := ethutil.U256(ethutil.BigD(sha.Sum(nil)))
+	res := ethutil.BigD(sha.Sum(nil))
 
 	return res.Cmp(verification) <= 0
 }
-- 
cgit v1.2.3


From db7c34a9df19d5a8a3a02a5e3d4cafcffa18dcb8 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Wed, 4 Feb 2015 18:34:29 -0800
Subject: Default gas price and default gas for rpc

---
 pow/ezp/pow.go | 2 --
 1 file changed, 2 deletions(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index 2791c4b0b..e4caa076a 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -1,7 +1,6 @@
 package ezp
 
 import (
-	"fmt"
 	"math/big"
 	"math/rand"
 	"time"
@@ -60,7 +59,6 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
 
 			sha := crypto.Sha3(big.NewInt(r.Int63()).Bytes())
 			if verify(hash, diff, sha) {
-				fmt.Printf("HASH: %x\nDIFF %v\nSHA %x\n", hash, diff, sha)
 				return sha
 			}
 		}
-- 
cgit v1.2.3


From da2fae0e437f9467a943acfe0571a8a24e8e76fd Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Mon, 9 Feb 2015 16:20:34 +0100
Subject: Basic structure miner

---
 pow/ezp/pow.go | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

(limited to 'pow/ezp/pow.go')

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) {
-- 
cgit v1.2.3


From 4d49d7b5a64774990c55dc2046195985bd716259 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Fri, 13 Feb 2015 18:30:06 +0100
Subject: Reset hash rate to 0 when mining is stopped

---
 pow/ezp/pow.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index 5571e73cd..f4a8b80e5 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -42,6 +42,8 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
 	starti := i
 	start := time.Now().UnixNano()
 
+	defer func() { pow.HashRate = 0 }()
+
 	// Make sure stop is empty
 empty:
 	for {
@@ -55,7 +57,6 @@ empty:
 	for {
 		select {
 		case <-stop:
-			pow.HashRate = 0
 			return nil
 		default:
 			i++
-- 
cgit v1.2.3


From 32c7ebc51dcb31f21efe1b9c75f2b86cd216f510 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Sat, 14 Feb 2015 16:52:14 +0100
Subject: Fixed mining & limited hash power

---
 pow/ezp/pow.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index f4a8b80e5..540381243 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -21,7 +21,7 @@ type EasyPow struct {
 }
 
 func New() *EasyPow {
-	return &EasyPow{turbo: true}
+	return &EasyPow{turbo: false}
 }
 
 func (pow *EasyPow) GetHashrate() int64 {
-- 
cgit v1.2.3


From 567428fb3489d639cd7fdcd50e4362be52745ec4 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Tue, 17 Feb 2015 16:12:55 +0100
Subject: Filter and mutex locks added

---
 pow/ezp/pow.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index 540381243..f4a8b80e5 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 {
-- 
cgit v1.2.3


From be90ad89a89502ef3d2c0375d267b667618f5e7c Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Wed, 18 Feb 2015 12:01:20 +0100
Subject: Disable turbo

---
 pow/ezp/pow.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index f4a8b80e5..540381243 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -21,7 +21,7 @@ type EasyPow struct {
 }
 
 func New() *EasyPow {
-	return &EasyPow{turbo: true}
+	return &EasyPow{turbo: false}
 }
 
 func (pow *EasyPow) GetHashrate() int64 {
-- 
cgit v1.2.3


From fa4cbad315609e41d88c59ecbce7c6c6169fc57a Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Thu, 19 Feb 2015 22:33:22 +0100
Subject: Optimisations and fixed a couple of DDOS issues in the miner

---
 pow/ezp/pow.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index 540381243..f4a8b80e5 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 {
-- 
cgit v1.2.3


From 9feb657763b85cd5beece82efc9e6477235b7d67 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Fri, 20 Feb 2015 18:06:45 +0100
Subject: Turbo off

---
 pow/ezp/pow.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'pow/ezp/pow.go')

diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index f4a8b80e5..540381243 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -21,7 +21,7 @@ type EasyPow struct {
 }
 
 func New() *EasyPow {
-	return &EasyPow{turbo: true}
+	return &EasyPow{turbo: false}
 }
 
 func (pow *EasyPow) GetHashrate() int64 {
-- 
cgit v1.2.3