Mining and Network Security

Mining Difficulty Adjustment Explained

How Bitcoin retargets mining difficulty every 2016 blocks to keep blocks near ten minutes, with a worked example, limits, and what it does and does not signal.

On this page
  1. The problem it solves
  2. What difficulty is
  3. The rule: every 2016 blocks
  4. Safety limits
  5. Why there is a lag
  6. Difficulty and hash rate
  7. Effects on miners and issuance
  8. What it does not do

The problem it solves

Bitcoin aims to produce a new block about every ten minutes. But the amount of computing power pointed at the network keeps changing as miners buy new machines, switch old ones off, or move between sites. If the rules were fixed, doubling the total computing power would double the speed at which blocks are found and, with it, the rate at which new coins are issued. The difficulty adjustment is the rule that prevents this by making the puzzle harder when blocks come too quickly and easier when they come too slowly.

What difficulty is

To be valid, a block’s hash must be below a target number, as explained in the article on how mining works. A smaller target means fewer acceptable hashes and therefore more attempts needed on average. Difficulty is simply a convenient way to express the target: it is a number that rises when the target falls and the work required grows. Specifically, difficulty compares the current target with the easiest target allowed by the protocol, so a difficulty of 1 would be the easiest setting, and higher values mean proportionally more average work.

The rule: every 2016 blocks

The network looks at how long the last 2016 blocks took. At ten minutes each, 2016 blocks should take 20,160 minutes, which is exactly two weeks. So:

  1. Measure the actual time the last 2016 blocks took.
  2. Compare it with the intended two weeks.
  3. Scale the target by the ratio between the two, then use that for the next 2016 blocks.

If the blocks arrived faster than two weeks, the target is lowered, which raises difficulty. If they were slower, the target is raised and difficulty falls.

A worked example

These numbers are illustrations. Suppose the last 2016 blocks took 12 days instead of 14 because more machines joined. The ratio of intended to actual time is 14 divided by 12, about 1.17. Difficulty rises by about 17 percent, so each attempt is a bit less likely to succeed. If the same computing power keeps going, blocks should then take about ten minutes again.

Now suppose the blocks took 16 days instead. The ratio 14 divided by 16 is 0.875, so difficulty falls by 12.5 percent.

Safety limits

The size of any single adjustment is capped. Difficulty cannot rise or fall by more than a factor of four in one step, however far the actual time was from two weeks. This stops wild swings, and also limits what a timestamp-manipulating attacker could achieve in one step.

There is also a well-known quirk: because of how the calculation counts intervals, it effectively measures the time across 2015 gaps instead of 2016. The effect is tiny and has been part of the protocol from the start, so it is treated as a historical detail rather than a problem.

Why there is a lag

The adjustment occurs only once per 2016 blocks. If a large share of miners switches off suddenly, the remaining ones face the old high difficulty and blocks can take much longer until the next retarget. In an extreme case, the wait could stretch for a long time because it takes 2016 slow blocks to reach the next adjustment. This lag is a design trade-off: frequent adjustments would react faster but could be noisier and easier to game. Some other cryptocurrencies adjust every block or use different formulas.

When blocks are slow, the mempool can fill up and transaction fees can rise, a pattern related to mempool congestion. Block times also vary randomly. Even with perfect calibration, individual blocks can arrive seconds or an hour apart, since finding a hash is a game of chance.

Difficulty and hash rate

Difficulty and hash rate are related but not the same thing. Hash rate is the total hashing power in use, estimated indirectly from how fast blocks are arriving and the current difficulty. Difficulty is a protocol setting that lags behind. If hash rate jumps between adjustments, blocks come faster; difficulty then catches up at the next retarget. Analysts watch both, but each has uncertainty. The article on hash rate as a network health indicator discusses how far such signals can be trusted.

Effects on miners and issuance

Higher difficulty means each machine finds fewer blocks on average, so a miner’s expected output falls unless it adds more capacity. This is one reason mining costs per coin tend to rise when competition grows, a theme explored in the production cost discussion.

For supply, the effect is the opposite of what might be expected: the adjustment keeps issuance close to the intended schedule. Because the reward halves at set block counts, not at set dates, the halving mechanics depend on block height, and the date of a halving shifts slightly if blocks arrive faster or slower than average.

What it does not do

Difficulty does not set the price, and a rising difficulty is not a promise of anything for the market. It reflects the competition among miners at a given time, which in turn reflects expectations, equipment availability and costs. Cryptocurrency prices are volatile and nothing here predicts future results. This article is educational and is not financial, tax or legal advice.

The complete guide to mining and network security

How Bitcoin Mining Works From Hashing to Block Rewards
Read the guide

Keep exploring

Guides from other topics

All topics →