Relationship between Hash-Rate and Difficulty

18

5

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

Kinnard Hockenhull

Posted 2012-11-30T18:35:56.870

Reputation: 2 285

Answers

18

Short answer:

  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.

Pieter Wuille

Posted 2012-11-30T18:35:56.870

Reputation: 54 032

1Can you elaborate on what max_target and intended time per block is? Are they constant? Located in the client? Are they calculated?goodguys_activate 2012-11-30T20:03:05.707

2max_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).Pieter Wuille 2012-11-30T20:17:44.940

Where does the 2^256 come from? Where did you find this info in the client? Thanks so much!!!Kinnard Hockenhull 2012-12-02T16:40:44.707

2@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.Meni Rosenfeld 2012-12-05T11:19:40.667

Unlikely that this is localized in any one part of the source code?Kinnard Hockenhull 2012-12-11T23:42:29.837