diff --git a/main.go b/main.go index c8414fe..4025010 100644 --- a/main.go +++ b/main.go @@ -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() } } diff --git a/proofofwork.go b/proofofwork.go index ff685b3..f97ec10 100644 --- a/proofofwork.go +++ b/proofofwork.go @@ -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 }