Bitcoin Core uses GetBlockProof() function to determine the contribution of a block to the total difficulty of the current chain, aka, nChainWork in CBlockIndex. I'm having trouble understanding the logic in that implementation.

Let's ignore the math gymnastics done there to avoid overflowing off uint256. The only part we need is the beginning of the comment:

// We need to compute 2**256 / (bnTarget+1)

And the question is simply, why?!

If I want to calculate the difficulty contribution of a block to the chain, my (possibly naive) logic would be: The lower the block hash value, the higher its contribution. While the equation mentioned in the comment achieves that, it doesn't do so linearly, but in a f(x)=1/x fashion. I don't get why. Again, my (possibly naive) implementation would simply be:

~arith_uint256(0) - UintToArith256(block.GetBlockHash())

which basically means: The lower the hash of a block, the higher its contribution to the difficulty. And if using the block hash is bad for some reason (I'd appreciate explaining why if it's the case), a similar proportionality can be made with just the target:

~arith_uint256(0) - bnTarget

Can someone please explain the reason for that division choice?

1 Answer 1


Any block, no matter how low its block hash is, contributes the same amount of work. This work depends on the current difficulty, as an average expected amount of work that should be performed to find this hash.
See these answers which explain the code you linked. Also this answer gives two examples of why the increased variance caused by making the work depend on the hash value isn't desirable.

  • Thank you for the links. This answers only why we're using the target instead of the block hash. It doesn't explain why division is used instead of difference like I showed in the question. Jun 21 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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