1

I'm developing a miner to study how mining works and I've connected it to a pool using Stratum. When I use the bits provided by the pool to calculate the target, it is different from the miner that I use (cpuminer). The target from cpuminer is easier than mine, like, the cpuminer target has 4 leading zeroes and mine has like 13 leading zeroes. I also noticed that the pool sends the difficulty, but I have no idea how should I use it.

How should I use the difficulty provided by the pool to calculate my target?

Edit: I've set it up to get difficulty 8 only.

cpuminer target: 00002000 00000000 00000000 00000000 ffffffff ffffffff ffffffff ffffffff

my target      : 00000000 0071c175 00000000 00000000 00000000 00000000 00000000 00000000
5
  • Is one using testnet and the other using mainnet? Commented Jun 19, 2021 at 20:48
  • Both are using the same stratum pool with the same difficulty (16). I also think cpuminer target is always the same for this difficulty, idk if there is another formula to calculate the target by difficulty number.
    – bot
    Commented Jun 20, 2021 at 15:10
  • Ops, difficulty 8*
    – bot
    Commented Jun 20, 2021 at 15:28
  • Are you talking about the block's "nbits" value, because that refers to the network-wide difficulty. Perhaps the other thing you see is the pool's share difficulty? Commented Jun 20, 2021 at 16:00
  • When the pool sends a work, it contains the "nbits" value which, in theory, should be used in block header, so I used it. The work also contains the mining difficulty, which I set to "8", but I don't know how I should use it. I asked this question because I don't know why cpuminer target is easier than mine, so probably I did something wrong and I want to know what.
    – bot
    Commented Jun 20, 2021 at 19:35

1 Answer 1

0

I searched for a few days and finally fixed my problem, thanks to https://bitcoin.stackexchange.com/a/23112/123635, it solved many problems that the documentation didn't clear up (like block hashing).

Basically, just do (in my case, with scrypt coins):

target = 0x0000FFFF00000000000000000000000000000000000000000000000000000000 / stratum difficulty

so:

target = 0x0000FFFF00000000000000000000000000000000000000000000000000000000 / 8

target = "00001fffe0000000000000000000000000000000000000000000000000000000"
1
  • if this answers your own question you should accept it
    – user112185
    Commented Jul 21, 2021 at 10:44

Your Answer

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

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