If the hash is bigger than the target, return false.. So if the hash is smaller than OR EQUAL TO the target, true is returned... #1 is correct (if i'm not mistaking)
Let's break this down to a simple example:
Target = 10
Scenario A: Check value 9
Scenario B: Check value 10
Scenario C: Check value 11
Code
return = true;
#Scenario A:
if (9 > 10 )
return false;
#Scenario A: returns ->true
#Scenario B:
if (10 > 10 )
return false;
#Scenario B: returns -> true
#Scenario C:
if (11 > 10)
return false;
#Scenario B: returns -> false
Conclusion: EQAUL TO (as in scenario B) returns true, meaning it is accepted. In other words: #2 is the correct one.
I'm on my employer's laptop, which only has php installed, so i wrote this analogy with the code:
<?php
$target = 10;
$hash = $target - 2;
$end = $target + 2;
while ($hash < $end)
{
echo "testing hash $hash vs target $target => ";
if ($hash > $target)
{
echo "POW does not match claimed ammount\n";
}
else
{
echo "OK!\n";
}
$hash++;
}
?>
response:
testing hash 8 vs target 10 => OK!
testing hash 9 vs target 10 => OK!
testing hash 10 vs target 10 => OK!
testing hash 11 vs target 10 => POW does not match claimed ammount
Since the OP was:
I still think #1 is correct, the function will return true if the hash is lower than or equal to the target
EDIT: after re-reading your reply and noticing your conclusion was the same as mine: the hash has to be lower than or equal to, i just realised one of us is just misinterpreting the OP...
We both conclude that hashes lower than or equal to the target are fine... It's just that my interpretation of sollution one is exactly correct, while my interpretation of sollution 2 says that only hashes lower than the target are true (which is not correct if i'm not mistaking)...