2

This is the line in xmr-stak where the hash is compared to the target:

if (*piHashVal < oWork.iTarget)
executor::inst()->push_event(ex_event(result, oWork.iPoolId));

However, if you look above, *piHashVal is defined as:

piHashVal = (uint64_t*)(result.bResult + 24);

Where result.bResult is the whole hash (a 32 byte long array), and it's just using the last 8 bytes of it.

Why not compare all 32 bytes to the target? And why is it comparing only the last 8 bytes? Does this mean that the code is little endian only?

3

It is little endian, and it compares only 8 bytes because it's lazy and if this matches, then the other 24 bytes don't matter (they'd matter if those 8 bytes were equal, in which case you're deemed not to have found a share, where you could have found one). This is probably done for some combination of speed and laziness.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.