func (pow *ProofOfWork) IsValid() bool {
	var hashInt big.Int

	// 1st round
	hash := sha256.Sum256(bytes.Join([][]byte{
		[]byte(pow.Data),
		intToHex(pow.Proof),
	}, []byte{}))

	// 2nd round of SHA256
	hash = sha256.Sum256(hash[:])
	hashInt.SetBytes(hash[:])

	target := big.NewInt(1)
	target = target.Lsh(target, uint(256-pow.Bits))

	return hashInt.Cmp(target) == -1
}
// IsValid returns true when the given work can be validated against the proof
IsValid returns true when the given work can be validated against the proof
// IsValid returns true when the given work can be validated against the proof
func (pow *ProofOfWork) IsValid() bool {
	var hashInt big.Int
	hash := sha256.Sum256(bytes.Join([][]byte{
		[]byte(pow.Data),
		intToHex(pow.Proof),
	}, []byte{}))
	hash = sha256.Sum256(hash[:])
	hashInt.SetBytes(hash[:])
	target := big.NewInt(1)
	target = target.Lsh(target, uint(256-pow.Bits))
	return hashInt.Cmp(target) == -1
}
func ( pow * ProofOfWork ) IsValid ( ) bool { var hashInt big . Int hash := sha256 . Sum256 ( bytes . Join ( [ ] [ ] byte { [ ] byte ( pow . Data ) , intToHex ( pow . Proof ) , } , [ ] byte { } ) ) hash = sha256 . Sum256 ( hash [ : ] ) hashInt . SetBytes ( hash [ : ] ) target := big . NewInt ( 1 ) target = target . Lsh ( target , uint ( 256 - pow . Bits ) ) return hashInt . Cmp ( target ) == - 1 }
IsValid returns true when the given work can be validated against the proof
IsValid returns true when the given work can be validated against the proof
// 1st round // 2nd round of SHA256