aboutsummaryrefslogtreecommitdiffstats
path: root/chain/dagger.go
diff options
context:
space:
mode:
Diffstat (limited to 'chain/dagger.go')
-rw-r--r--chain/dagger.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/chain/dagger.go b/chain/dagger.go
index 2cf70e091..a0ccaeeca 100644
--- a/chain/dagger.go
+++ b/chain/dagger.go
@@ -81,13 +81,17 @@ func (pow *EasyPow) Verify(hash []byte, diff *big.Int, nonce []byte) bool {
d := append(hash, nonce...)
sha.Write(d)
- v := ethutil.BigPow(2, 256)
- ret := new(big.Int).Div(v, diff)
+ verification := new(big.Int).Div(ethutil.BigPow(2, 256), diff)
+ res := ethutil.U256(ethutil.BigD(sha.Sum(nil)))
- res := new(big.Int)
- res.SetBytes(sha.Sum(nil))
+ /*
+ fmt.Printf("hash w/o nonce %x\n", hash)
+ fmt.Printf("2**256 / %v = %v\n", diff, verification)
+ fmt.Printf("%v <= %v\n", res, verification)
+ fmt.Printf("vlen: %d rlen: %d\n", len(verification.Bytes()), len(res.Bytes()))
+ */
- return res.Cmp(ret) == -1
+ return res.Cmp(verification) <= 0
}
func (pow *EasyPow) SetHash(hash *big.Int) {