From 8653db6df0018d08212493e3a3df4677162bdd8f Mon Sep 17 00:00:00 2001 From: Matthew Wampler-Doty Date: Fri, 27 Feb 2015 15:59:33 -0500 Subject: Introducign MixDigest and SeedHash --- 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..8808d7ce0 100644 --- a/pow/ezp/pow.go +++ b/pow/ezp/pow.go @@ -96,5 +96,5 @@ func verify(hash []byte, diff *big.Int, nonce []byte) bool { } func Verify(block pow.Block) bool { - return verify(block.HashNoNonce(), block.Difficulty(), block.N()) + return verify(block.HashNoNonce(), block.Difficulty(), block.Nonce()) } -- cgit v1.2.3 From de9f79133faa1ff5dcd16fb4fd13d06b7799ded9 Mon Sep 17 00:00:00 2001 From: Matthew Wampler-Doty Date: Sat, 28 Feb 2015 14:58:37 -0500 Subject: Introducing ethash --- pow/ezp/pow.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'pow/ezp/pow.go') diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go index 8808d7ce0..49854c3d0 100644 --- a/pow/ezp/pow.go +++ b/pow/ezp/pow.go @@ -32,7 +32,7 @@ func (pow *EasyPow) Turbo(on bool) { pow.turbo = on } -func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte { +func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) ([]byte, []byte, []byte) { r := rand.New(rand.NewSource(time.Now().UnixNano())) hash := block.HashNoNonce() diff := block.Difficulty() @@ -57,7 +57,7 @@ empty: for { select { case <-stop: - return nil + return nil, nil, nil default: i++ @@ -67,7 +67,7 @@ empty: sha := crypto.Sha3(big.NewInt(r.Int63()).Bytes()) if verify(hash, diff, sha) { - return sha + return sha, nil, nil } } @@ -75,8 +75,6 @@ empty: time.Sleep(20 * time.Microsecond) } } - - return nil } func (pow *EasyPow) Verify(block pow.Block) bool { -- cgit v1.2.3 From 26de12d9bf23bce7de26b3b6629601ec2e58ad5b Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 3 Mar 2015 21:04:31 +0100 Subject: Changed nonce to a uint64 --- pow/ezp/pow.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'pow/ezp/pow.go') diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go index 49854c3d0..3ca502d06 100644 --- a/pow/ezp/pow.go +++ b/pow/ezp/pow.go @@ -1,11 +1,11 @@ package ezp import ( + "encoding/binary" "math/big" "math/rand" "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" @@ -32,7 +32,7 @@ func (pow *EasyPow) Turbo(on bool) { pow.turbo = on } -func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) ([]byte, []byte, []byte) { +func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) (uint64, []byte, []byte) { r := rand.New(rand.NewSource(time.Now().UnixNano())) hash := block.HashNoNonce() diff := block.Difficulty() @@ -57,7 +57,7 @@ empty: for { select { case <-stop: - return nil, nil, nil + return 0, nil, nil default: i++ @@ -65,7 +65,7 @@ empty: hashes := ((float64(1e9) / float64(elapsed)) * float64(i-starti)) / 1000 pow.HashRate = int64(hashes) - sha := crypto.Sha3(big.NewInt(r.Int63()).Bytes()) + sha := uint64(r.Int63()) if verify(hash, diff, sha) { return sha, nil, nil } @@ -75,16 +75,20 @@ empty: time.Sleep(20 * time.Microsecond) } } + + return 0, nil, nil } func (pow *EasyPow) Verify(block pow.Block) bool { return Verify(block) } -func verify(hash []byte, diff *big.Int, nonce []byte) bool { +func verify(hash []byte, diff *big.Int, nonce uint64) bool { sha := sha3.NewKeccak256() - d := append(hash, nonce...) + n := make([]byte, 8) + binary.PutUvarint(n, nonce) + d := append(hash, n...) sha.Write(d) verification := new(big.Int).Div(ethutil.BigPow(2, 256), diff) -- cgit v1.2.3