zone117x / node-cryptonote-pool

Mining pool for CryptoNote based coins such as Bytecoin and Monero
GNU General Public License v2.0
824 stars 1.14k forks source link

Understanding how `getTargetHex` function works #223

Closed kgritesh closed 6 years ago

kgritesh commented 6 years ago

Thanks a lot for a great library. I learned a lot about monero and mining pools from this code. However i had couple of questions which i am not able to understand. I guess this is not an issue as much as a request to understand how do we calculate target hash for a job. As far as i understand
from here

target = <max target> / difficulty

However in the implementation we only take first 4 bytes of the target and reverse them. Infact i saw that even the other open source mining pools does the same thing. I have spent couple of days trying to figure this out, but have still been stumped. Would really appreciate if you could help with this

zone117x commented 6 years ago

It's been years since that was figured out. I believe its that way due to basing the target difficulty format on the original mining protocol used by Minergate's mining client. The byte reversal I believe is an endian swap, and the 4 bytes thing is possibly due to not needing the extra precision. Sorry I can't be of more help.

kgritesh commented 6 years ago

@zone117x Thanks a lot for your reply. I guess i will have to accept it as it is. Thanks anyways for the answer and for opensourcing this. Great learning experience