Rename ConfirmProof function to Validate

This commit is contained in:
Ivan Kuznetsov 2017-08-24 10:35:14 +07:00
parent d379fdeae2
commit 2a9385dd5b
2 changed files with 5 additions and 5 deletions

View File

@ -16,7 +16,7 @@ func main() {
fmt.Printf("Data: %s\n", block.Data)
fmt.Printf("Hash: %x\n", block.Hash)
pow := NewProofOfWork(block)
fmt.Printf("PoF: %s\n", strconv.FormatBool(pow.ConfirmProof()))
fmt.Printf("PoW: %s\n", strconv.FormatBool(pow.Validate()))
fmt.Println()
}
}

View File

@ -70,15 +70,15 @@ func (pow *ProofOfWork) Run() (int, []byte) {
return nonce, hash[:]
}
// ConfirmProof confirms that the proof is correct
func (pow *ProofOfWork) ConfirmProof() bool {
// Validate validates block's PoW
func (pow *ProofOfWork) Validate() bool {
var hashInt big.Int
data := pow.prepareData(pow.block.Nonce)
hash := sha256.Sum256(data)
hashInt.SetBytes(hash[:])
confirmation := hashInt.Cmp(pow.target) == -1
isValid := hashInt.Cmp(pow.target) == -1
return confirmation
return isValid
}