mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 07:26:51 +00:00
move spam check up in logic
This commit is contained in:
@@ -53,15 +53,6 @@ pub fn process_mine(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult {
|
||||
return Err(OreError::NeedsReset.into());
|
||||
}
|
||||
|
||||
// Validate the hash digest.
|
||||
//
|
||||
// Here we use drillx to validate the provided solution is a valid hash of the challenge.
|
||||
// If invalid, we return an error.
|
||||
let solution = Solution::new(args.digest, args.nonce);
|
||||
if !solution.is_valid(&proof.challenge) {
|
||||
return Err(OreError::HashInvalid.into());
|
||||
}
|
||||
|
||||
// Reject spam transactions.
|
||||
//
|
||||
// If a miner attempts to submit solutions too frequently, we reject with an error. In general,
|
||||
@@ -73,6 +64,15 @@ pub fn process_mine(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult {
|
||||
return Err(OreError::Spam.into());
|
||||
}
|
||||
|
||||
// Validate the hash digest.
|
||||
//
|
||||
// Here we use drillx to validate the provided solution is a valid hash of the challenge.
|
||||
// If invalid, we return an error.
|
||||
let solution = Solution::new(args.digest, args.nonce);
|
||||
if !solution.is_valid(&proof.challenge) {
|
||||
return Err(OreError::HashInvalid.into());
|
||||
}
|
||||
|
||||
// Validate the hash satisfies the minimum difficulty.
|
||||
//
|
||||
// We use drillx to get the difficulty (leading zeros) of the hash. If the hash does not have the
|
||||
|
||||
Reference in New Issue
Block a user