Bitcoin hash charges/problem – Bitcoin Stack Trade


Difficulty is defined relatively: it is how much more difficult it is to mine a block compared to a fixed “maximum target”, which corresponds to roughly 232 hashes.

In more detail, a Bitcoin block is PoW-valid when its hash (interpreted as a 256-bit integer) is less or equal to that block’s “target”. Difficulty does not exist at the protocol level; internally, everything uses targets.

The rules for target adjustment are as follows:

  • Blocks whose height n is not a multiple of 2016 have the same target as their parent block.
  • Blocks whose height n is a multiple of 2016:
    • Take the parent’s target
    • Multiply that target by the number of seconds in two weeks.
    • Divide the result by the difference (in seconds) between the timestamp of block n-2016 and that of block n-1.
    • If the result is more than 4 times the parent target, or less than 1/4th of the parent target, clamp it.
    • If the result is above the maximum target, use the maximum target instead.
    • Round the target down to fit in Bitcoin’s custom 32-bit floating point format (called the “nBits” encoding).

The expected number of hashes at a given target T is 2256 / (T+1). The higher the target, the easier it is to mine a block. The maximum target is thus a limit on how easy mining can get, and is the fixed constant (2224 – 2208) in Bitcoin. The expected number of hashes at this target is 248 / (216-1), or just over 232.

The difficulty is now a purely human representation of the target value: it is the maximum target divided by the actual target, and is at least 1 (at maximum target).

Leave a Comment

Your email address will not be published.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.