diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-03 20:50:51 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-03 20:50:51 +0800 |
commit | 6095edac5843aa18e389ef2deaa49fe05b7fcfb9 (patch) | |
tree | 851b5616b2024248b6b9790199ef289e04725cbb /chain/dagger.go | |
parent | 64f35ba8d1f31d6821a0a1bf946c71396a996f30 (diff) | |
parent | 3d9a4e7084c33cb28a2265c0dd232a0ea3871c92 (diff) | |
download | go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar.gz go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar.bz2 go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar.lz go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar.xz go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar.zst go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.zip |
merge
Diffstat (limited to 'chain/dagger.go')
-rw-r--r-- | chain/dagger.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/chain/dagger.go b/chain/dagger.go index f7e2229e9..507850389 100644 --- a/chain/dagger.go +++ b/chain/dagger.go @@ -82,13 +82,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) { |