This commit is contained in:
obscuren
2014-12-15 11:37:23 +01:00
parent 1d959cb0ca
commit f111fc0608
2 changed files with 18 additions and 47 deletions

View File

@ -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())
}