1

What is an algorithm to determine what maximum difficulty already found hash meets?

2

See https://en.bitcoin.it/wiki/Difficulty#How_is_difficulty_calculated.3F_What_is_the_difference_between_bdiff_and_pdiff.3F

For example, block #347444:

0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 
0x000000000000000014a5256523f37dd374dcb1e0840a85ab4d0cea60bad043d8
= 53256935148.82868

For fun, we can calculate the difficulty the smallest block hash ever mined (as of block #347444) could have satisfied.

First lets get the list from my Bitcoin Abe database:

MariaDB [abe]> SELECT hex(block_hash), block_height FROM block ORDER BY block_hash ASC LIMIT 10;
+------------------------------------------------------------------+--------------+
| hex(block_hash)                                                  | block_height |
+------------------------------------------------------------------+--------------+
| 000000000000000000002D414BB8F9175BA6C6563721E1BA2C1373C2BD94F29F |       334261 |
| 000000000000000000005A5E143087632FBF0EEA743AD99646D9FC67D40F7441 |       336175 |
| 000000000000000000006836C4009AB00485CD1DE4D5958CA7839184D0B80067 |       331908 |
| 000000000000000000007E1166D92ACF81D4E2D95934FCDEC1276B09A7DB9390 |       326055 |
| 000000000000000000007EEF13EE1F2FCF1B469BD862FCC93B48EC49548ECF6D |       343775 |
| 000000000000000000008AC86BA28085BE84AF2EBD6FC6935A004E57FB60C083 |       340483 |
| 00000000000000000000B7DE9E5C19E52BE073156924B7CF235EFB27AE8A202A |       313338 |
| 00000000000000000000EC03E3183BACC8B18437180F63F6A563267A186225BC |       331987 |
| 0000000000000000000119ADB3DA72742B1EBA98F9DC26F73858E91652B42287 |       334151 |
| 0000000000000000000119F88871F8A3C3B7BE053C98B31E9C4676DF30243CFE |       333904 |
+------------------------------------------------------------------+--------------+
10 rows in set (0.06 sec)

Then we pass that to Python (I ran a modified version of the query above to print a format Python understands):

>>> # 334261
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000002D414BB8F9175BA6C6563721E1BA2C1373C2BD94F29F
1592230611213387.2
>>> # 336175
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000005A5E143087632FBF0EEA743AD99646D9FC67D40F7441
797371821285215.2
>>> # 331908
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000006836C4009AB00485CD1DE4D5958CA7839184D0B80067
691428638477639.5
>>> # 326055
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000007E1166D92ACF81D4E2D95934FCDEC1276B09A7DB9390
571568585825999.9
>>> # 343775
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000007EEF13EE1F2FCF1B469BD862FCC93B48EC49548ECF6D
567669438511087.9
>>> # 340483
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x000000000000000000008AC86BA28085BE84AF2EBD6FC6935A004E57FB60C083
519203003284590.0
>>> # 313338
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x00000000000000000000B7DE9E5C19E52BE073156924B7CF235EFB27AE8A202A
391889105139868.25
>>> # 331987
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x00000000000000000000EC03E3183BACC8B18437180F63F6A563267A186225BC
305304486446787.75
>>> # 334151
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x0000000000000000000119ADB3DA72742B1EBA98F9DC26F73858E91652B42287
255811103719832.1
>>> # 333904
... 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / 0x0000000000000000000119F88871F8A3C3B7BE053C98B31E9C4676DF30243CFE
255545915930877.94

Therefore the highest difficulty target ever attained as of block #347444 is 1,592,230,611,213,387.2 for block #334261

NB: Use Python 3 to get decimals, Python 2.x truncates the fractional digits.

  • Of course, as @NickODell pointed out in another answer, the hashed block data includes its difficulty, so this is all theoretical, the block still satisfies only the difficulty it was mined for and that cannot be changed. – Thomas Guyot-Sionnest Mar 13 '15 at 15:08
1

A hash only meets one difficulty, because when mining, you set a field called nBits, which describes the difficulty you were mining for. You cannot change this field without changing the hash and starting over.

bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
[...]
if (UintToArith256(hash) > bnTarget)

(source)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.