Integrate new ethash API and change geth makedag cmd
This commit is contained in:
@@ -6,8 +6,8 @@ import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/crypto/sha3"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto/sha3"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
)
|
||||
|
||||
@@ -44,7 +44,7 @@ func (dag *Dagger) Find(obj *big.Int, resChan chan int64) {
|
||||
resChan <- 0
|
||||
}
|
||||
|
||||
func (dag *Dagger) Search(hash, diff *big.Int) ([]byte, []byte, []byte) {
|
||||
func (dag *Dagger) Search(hash, diff *big.Int) (uint64, []byte) {
|
||||
// TODO fix multi threading. Somehow it results in the wrong nonce
|
||||
amountOfRoutines := 1
|
||||
|
||||
@@ -69,7 +69,7 @@ func (dag *Dagger) Search(hash, diff *big.Int) ([]byte, []byte, []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
return big.NewInt(res).Bytes(), nil, nil
|
||||
return uint64(res), nil
|
||||
}
|
||||
|
||||
func (dag *Dagger) Verify(hash, diff, nonce *big.Int) bool {
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ func (pow *EasyPow) Turbo(on bool) {
|
||||
pow.turbo = on
|
||||
}
|
||||
|
||||
func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) (uint64, []byte, []byte) {
|
||||
func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) (uint64, []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 0, nil, nil
|
||||
return 0, nil
|
||||
default:
|
||||
i++
|
||||
|
||||
@@ -67,7 +67,7 @@ empty:
|
||||
|
||||
sha := uint64(r.Int63())
|
||||
if verify(hash, diff, sha) {
|
||||
return sha, nil, nil
|
||||
return sha, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ empty:
|
||||
}
|
||||
}
|
||||
|
||||
return 0, nil, nil
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (pow *EasyPow) Verify(block pow.Block) bool {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package pow
|
||||
|
||||
type PoW interface {
|
||||
Search(block Block, stop <-chan struct{}) (uint64, []byte, []byte)
|
||||
Search(block Block, stop <-chan struct{}) (uint64, []byte)
|
||||
Verify(block Block) bool
|
||||
GetHashrate() int64
|
||||
Turbo(bool)
|
||||
|
||||
Reference in New Issue
Block a user