https://litecoin.info/index.php?title=Difficulty&feed=atom&action=historyDifficulty - Revision history2024-03-29T10:46:10ZRevision history for this page on the wikiMediaWiki 1.30.0https://litecoin.info/index.php?title=Difficulty&diff=38&oldid=prevAdmin: Created page with "'''Difficulty''' is a measure of how difficult it is to find a new block. It is a human-friendly way of expressing the target. === How often does the difficulty chang..."2018-02-12T10:57:51Z<p>Created page with "'''Difficulty''' is a measure of how difficult it is to find a new <a href="/index.php?title=Block&action=edit&redlink=1" class="new" title="Block (page does not exist)">block</a>. It is a human-friendly way of expressing the <a href="/index.php?title=Target&action=edit&redlink=1" class="new" title="Target (page does not exist)">target</a>. === How often does the difficulty chang..."</p>
<p><b>New page</b></p><div>'''Difficulty''' is a measure of how difficult it is to find a new [[block]]. It is a human-friendly way of expressing the [[target]].<br />
<br />
=== How often does the difficulty change? ===<br />
Every 2016 blocks.<br />
<br />
=== What is the formula for difficulty? ===<br />
Difficulty can be computed from the current target (which is a 256-bit number) as follows:<br />
difficulty = 0xFFFF * 2**208 / target<br />
<br />
===How is difficulty stored in blocks?===<br />
Each block stores a packed representation (called "Bits") for its actual hexadecimal target. The target can be derived from it via a predefined formula. For example, if the packed target in the block is 0x1b0404cb, the hexadecimal target is<br />
0x0404cb * 2**(8*(0x1b - 3)) = 0x00000000000404CB000000000000000000000000000000000000000000000000<br />
<br />
Note that the 0x0404cb value is a signed value in this format. The largest legal value for this field is 0x7fffff. To make a larger value you must shift it down one full byte. Also 0x008000 is the smallest positive valid value.<br />
<br />
Difficulty 1 (which is not the lowest difficulty) corresponds to 0x1d00ffff, which gives us a hex target of<br />
0x00ffff * 2**(8*(0x1d - 3)) = 0x00000000FFFF0000000000000000000000000000000000000000000000000000<br />
<br />
=== What is the current difficulty? ===<br />
* [http://litecoinscout.com/static/ Litecoin difficulty charts]<br />
<br />
=== What is the maximum difficulty? ===<br />
There is no minimum target. The maximum difficulty is roughly: maximum_target / 1 (since 0 would result in infinity), which is a ridiculously huge number (about 2^224). <br />
<br />
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.)<br />
<br />
=== Can the difficulty go down? ===<br />
Yes it can. See discussion in [[target]].<br />
<br />
=== What is the minimum difficulty? ===<br />
The minimum difficulty allowed by Litecoin is 2<sup>-12</sup>, or about 0.00024414.<br />
<br />
=== What network hash rate results in a given difficulty? ===<br />
The difficulty is adjusted every 2016 blocks based on the time it took to find the previous 2016 blocks. At the desired rate of one block every 2.5 minutes, 2016 blocks would take exactly 3.5 days to find. If the previous 2016 blocks took more than 3.5 days to find, the difficulty is reduced. If they took less than 3.5 days, the difficulty is increased. The change in difficulty is in proportion to the amount of time over or under 3.5 days the previous 2016 blocks took to find.<br />
<br />
To find a block, the [[scrypt]] hash must be less than the target. This hash is effectively a random number between 0 and 2**256-1. The offset for difficulty 1 is<br />
0xffff * 2**208<br />
and for difficulty D is<br />
(0xffff * 2**208) / D<br />
<br />
The expected number of hashes we need to calculate to find a block with difficulty D is therefore<br />
D * 2**256 / (0xffff * 2**208)<br />
or just<br />
D * 2**48 / 0xffff<br />
<br />
The difficulty is set such that the previous 2016 blocks would have been found at the rate of one every 2.5 minutes, so we were calculating (D * 2**48 / 0xffff) hashes in 150 seconds. That means the hash rate of the network was<br />
D * 2**48 / 0xffff / 150<br />
over the previous 2016 blocks. Can be further simplified to<br />
D * 2**32 / 150<br />
without much loss of accuracy.<br />
<br />
At difficulty 1, that is around 28 Mhashes per second.<br />
<br />
At the time of writing, the difficulty is 1169.85315079, which means that over the previous set of 2016 blocks found the average network hash rate was<br />
1169.85315079 * 2**32 / 150 = around 33 Ghashes per second.<br />
<br />
=== How soon might I expect to generate a block? ===<br />
(The [https://www.bitcointalk.org/index.php?topic=1682.0 eternal question].)<br />
<br />
The average time to find a block can be approximated by calculating:<br />
time = difficulty * 2**32 / hashrate<br />
where difficulty is the current difficulty, hashrate is the number of hashes your miner calculates per second, and time is the average in seconds between the blocks you find.<br />
<br />
For example, using Python we calculate the average time to generate a block using a 1-Mhash/s mining rig when the difficulty is 1000:<br />
$ python -c "print 1000 * 2**32 / 1e6 / 60 / 60 / 24"<br />
49.7102696296<br />
and find that it would take almost 50 days on average.<br />
<br />
* 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.<br />
* You need to know the difficulty (above) and your khash/sec rate (reported by the client).<br />
** [[Mining Hardware Comparison]] has some stats that may help you predict what you could get.<br />
* Visit a calculator or perform the maths yourself,<br />
** http://allchains.info/calc.html<br />
** http://www.litecoinpool.org/calc<br />
* Remember it's just probability! There are no guarantees you will win every N days.<br />
<br />
== Related articles ==<br />
* [[Target]]<br />
<br />
{{borrowedfromBitcoin}}<br />
<br />
[[Category:Technical]]</div>Admin