From f111fc060884d69fbe46066b9ccae4c9aa5da890 Mon Sep 17 00:00:00 2001 From: obscuren 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') 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 49e0267fe76cfd13eaf3e5e26caa637b93dbdd29 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Dec 2014 13:12:54 +0100 Subject: Locks, refactor, tests * Added additional chain tests * Added proper mutex' on chain * Removed ethereum dependencies --- pow/ezp/pow.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pow') diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go index cdf89950f..bfe3ea098 100644 --- a/pow/ezp/pow.go +++ b/pow/ezp/pow.go @@ -21,7 +21,7 @@ type EasyPow struct { } func New() *EasyPow { - return &EasyPow{} + return &EasyPow{turbo: true} } func (pow *EasyPow) GetHashrate() int64 { -- cgit v1.2.3 From 4cd79d8ddd7608d60344b13fe4bda7315429d1d9 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 23 Dec 2014 13:48:44 +0100 Subject: Refactored block & Transaction * Includes new rlp decoder --- pow/block.go | 2 +- pow/ezp/pow.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'pow') diff --git a/pow/block.go b/pow/block.go index 4759e19fb..62df2b5ff 100644 --- a/pow/block.go +++ b/pow/block.go @@ -3,7 +3,7 @@ package pow import "math/big" type Block interface { - Diff() *big.Int + Difficulty() *big.Int HashNoNonce() []byte N() []byte } 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