Change PoW error (#1234)

* Use proper error for invalid PoW

* Add comment
This commit is contained in:
Ori Newman 2020-12-16 13:33:10 +02:00 committed by GitHub
parent dc3ae4d3ac
commit b510fc08a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -97,7 +97,7 @@ func (v *blockValidator) checkProofOfWork(header *externalapi.DomainBlockHeader)
if !v.skipPoW { if !v.skipPoW {
valid := pow.CheckProofOfWorkWithTarget(header, target) valid := pow.CheckProofOfWorkWithTarget(header, target)
if !valid { if !valid {
return errors.Wrap(ruleerrors.ErrUnexpectedDifficulty, "block has invalid difficulty") return errors.Wrap(ruleerrors.ErrInvalidPoW, "block has invalid proof of work")
} }
} }
return nil return nil

View File

@ -44,6 +44,9 @@ var (
// range. // range.
ErrUnexpectedDifficulty = newRuleError("ErrUnexpectedDifficulty") ErrUnexpectedDifficulty = newRuleError("ErrUnexpectedDifficulty")
// ErrInvalidPoW indicates that the block proof-of-work is invalid.
ErrInvalidPoW = newRuleError("ErrInvalidPoW")
// ErrHighHash indicates the block does not hash to a value which is // ErrHighHash indicates the block does not hash to a value which is
// lower than the required target difficultly. // lower than the required target difficultly.
ErrHighHash = newRuleError("ErrHighHash") ErrHighHash = newRuleError("ErrHighHash")
@ -56,7 +59,7 @@ var (
// the expected value. // the expected value.
ErrBadUTXOCommitment = newRuleError("ErrBadUTXOCommitment") ErrBadUTXOCommitment = newRuleError("ErrBadUTXOCommitment")
// ErrInvalidSubnetwork indicates the subnetwork is now allowed. // ErrInvalidSubnetwork indicates the subnetwork is not allowed.
ErrInvalidSubnetwork = newRuleError("ErrInvalidSubnetwork") ErrInvalidSubnetwork = newRuleError("ErrInvalidSubnetwork")
// ErrFinalityPointTimeTooOld indicates a block has a timestamp before the // ErrFinalityPointTimeTooOld indicates a block has a timestamp before the