Difference between revisions of "Difficulty"

From Bitcoin Wiki
Jump to: navigation, search
m (How is difficulty stored in blocks?: wrap long unformatted line)
(How is difficulty stored in blocks?: either '<<' or '2**' (they're equivalent), but not both!)
Line 18: Line 18:
  
 
Difficulty is stored in blocks as a 4 byte integer, and the actual hexadecimal [[target]] is derived from it via a predefined formula. For example, if the difficulty in the block is 0x1b0404cb, the hexadecimal target is
 
Difficulty is stored in blocks as a 4 byte integer, and the actual hexadecimal [[target]] is derived from it via a predefined formula. For example, if the difficulty in the block is 0x1b0404cb, the hexadecimal target is
  0x0404cb << 2**(8*(0x1b - 3)) = 0x00000000000404CB000000000000000000000000000000000000000000000000
+
  0x0404cb * 2**(8*(0x1b - 3)) = 0x00000000000404CB000000000000000000000000000000000000000000000000
  
 
The highest possible target (difficulty 1) is defined as 0x1d00ffff, which gives us a hex target of
 
The highest possible target (difficulty 1) is defined as 0x1d00ffff, which gives us a hex target of
  0x00ffff << 2**(8*(0x1d - 3)) = 0x00000000FFFF0000000000000000000000000000000000000000000000000000
+
  0x00ffff * 2**(8*(0x1d - 3)) = 0x00000000FFFF0000000000000000000000000000000000000000000000000000
  
 
So the difficulty at 0x1b0404cb is therefore:
 
So the difficulty at 0x1b0404cb is therefore:

Revision as of 10:15, 17 January 2011

See also: target

What is "difficulty"?

Difficulty is a measure of how difficult it is to find a new block compared to the easiest it can ever be.

How often does the difficulty change?

Every 2016 blocks.

What is the formula for difficulty?

difficulty = maximum_target / current_target

(target is a 256 bit number)

How is difficulty stored in blocks?

Difficulty is stored in blocks as a 4 byte integer, and the actual hexadecimal target is derived from it via a predefined formula. For example, if the difficulty in the block is 0x1b0404cb, the hexadecimal target is

0x0404cb * 2**(8*(0x1b - 3)) = 0x00000000000404CB000000000000000000000000000000000000000000000000

The highest possible target (difficulty 1) is defined as 0x1d00ffff, which gives us a hex target of

0x00ffff * 2**(8*(0x1d - 3)) = 0x00000000FFFF0000000000000000000000000000000000000000000000000000

So the difficulty at 0x1b0404cb is therefore:

0x00000000FFFF0000000000000000000000000000000000000000000000000000 /
0x00000000000404CB000000000000000000000000000000000000000000000000 
= 16307.420938523983

What is the current difficulty?

Current difficulty, as output by BitCoin's getDifficulty.

Difficulty History

What is the maximum difficulty?

The maximum difficulty is roughly: maximum_target / 1, which is a ridiculously huge number (about 2^224).

The actual maximum difficulty is when current_target=0, but we would not be able to calculate the difficulty if that happened. (fortunately it never will, so we're ok.)

Can the difficulty go down?

Yes it can. See discussion in target.

What is the minimum difficulty?

The minimum difficulty, when the target is at the maximum allowed value, is 1.

How soon might I expect to generate a block?

(The eternal question.)

  • Any one grinding of the hash stands the same chance of "winning" as any other. The numbers game is how many attempts your hardware can make per second.
  • You need to know the difficulty (above) and your khash/sec rate (reported by the client).
  • Visit a calculator or perform the maths yourself,
  • Remember it's just probability! There are no guarantees you will win every N days.

This article uses content from the old wiki. The list of contributors to the old page is available here.