# Relationship between Hash-Rate and Difficulty

What is the algebraic relationship between Total Network Hash-Rate and Difficulty?

``````  difficulty = hashrate / (2^256 / max_target / intended_time_per_block)
= hashrate / (2^256 / (2^208*65535) / 600)
= hashrate / (2^48 / 65535 / 600)
= hashrate / 7158388.055
``````

(where hashrate is expressed in hashes/s)

Longer answer: there is no direct relation between the actual network hashrate and the difficulty, because the actual hashrate cannot be observed. What happens is that every 2016 blocks, the average hashrate during that period is measured, and the difficulty is adjusted based on that.

• Can you elaborate on what max_target and intended time per block is? Are they constant? Located in the client? Are they calculated? Commented Nov 30, 2012 at 20:03
• max_target is 2^208*65535 (an application-defined constant, which sets the target hash corresponding to the lowest possible difficulty, 1), and intended_time_per_block is 600 (10 minutes, also a constant). Commented Nov 30, 2012 at 20:17
• Where does the 2^256 come from? Where did you find this info in the client? Thanks so much!!! Commented Dec 2, 2012 at 16:40
• @KinnardHockenhull: Hashes are 256-bit integers. The target is max_target/difficulty, so (2^256*difficulty/max_target) hashes are needed on average to find a block. So the difficulty will be the value that makes the average time for the network to find a block equal to the intended time. Commented Dec 5, 2012 at 11:19

difficulty = hashrate / (2^32-2^16) / 600 ) = hashrate / 7158170 ~ hashrate / (2^32 / 600)

as 2^32-2^16=0xFFFF0000 in hex, a magic constant in the code.

• Hey there @Adam Back. How'd you wander upon this question? Commented May 9, 2021 at 22:31