0

I'm trying to determine how to properly convert difficulty from a mining.set_difficulty message to target for Litecoin, similar to how it's done for Bitcoin.

For Bitcoin, the process I use is as follows:

  1. I start with the genesis nbits value: 0x1d00ffff
  2. I convert this to the max target:
    0x00000000ffff0000000000000000000000000000000000000000000000000000
    
  3. Then, I calculate the target using this formula:
    target = max_target / difficulty
    
    For example, with a difficulty of 524288, the target becomes:
    target = max_target / 524288 = 0x0000000000001fffe00000000000000000000000000000000000000000000000
    

Now, I'm trying to apply a similar algorithm to Litecoin. Here's what I have so far:

  1. The genesis nbits for Litecoin is 0x1e0ffff0
  2. I convert this to the same max target as in Bitcoin:
    0x00000ffff0000000000000000000000000000000000000000000000000000000
    
  3. I use the formula max_target / 524288, which results in the same target as in Bitcoin:
    target = 0x0000000001fffe00000000000000000000000000000000000000000000000000
    

However, when I perform this calculation and compare it with the shares I receive on the pool side, I find that shares have a higher target, such as:

0x0000000005713013fcbf8bf0dcc329a5f56b856c2dbe64603e34b47169eaaa50 (pow)
>
0x0000000001fffe00000000000000000000000000000000000000000000000000 (target)

Upon further investigation, I found this code snippet, which introduces a coefficient of 65535:

if (opt_algo == ALGO_SCRYPT)
    diff_to_target(work->target, sctx->job.diff / 65536.0);
else
    diff_to_target(work->target, sctx->job.diff);

This suggests that the target for Litecoin should be multiplied by 65535. My question is:

  • Should the target be scaled by 65535 in the same way?
  • Why is this adjustment necessary for Scrypt (Litecoin) but not for Bitcoin?
  • How do I correctly calculate the target for Litecoin to avoid getting shares higher than the calculated target?

Any guidance on this would be appreciated!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.