bitcoin difficulty bits

See also: target Contents 1 2 3 4 5 6 7 8 9 Difficulty is a measure of how difficult it is to find a hash below a given target.The Bitcoin network has a global block difficulty.Valid blocks must have a hash below this target.Mining pools also have a pool-specific share difficulty setting a lower limit for shares.difficulty = difficulty_1_target / current_target (target is a 256 bit number) difficulty_1_target can be different for various ways to measure difficulty.Traditionally, it represents a hash where the leading 32 bits are zero and the rest are one (this is known as "pool difficulty" or "pdiff").The Bitcoin protocol represents targets as a custom floating point type with limited precision; as a result, Bitcoin clients often approximate difficulty based on this (this is known as "bdiff").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 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.The highest possible target (difficulty 1) is defined as 0x1d00ffff, which gives us a hex target of It should be noted that pooled mining often uses non-truncated targets, which puts "pool difficulty 1" at So the difficulty at 0x1b0404cb is therefore: And: Here's a fast way to calculate bitcoin difficulty.It uses a modified Taylor series for the logarithm (you can see tutorials on flipcode and wikipedia) and relies on logs to transform the difficulty calculation: To see the math to go from the normal difficulty calculations (which require large big ints bigger than the space in any normal integer) to the calculation above, here's some python: Current difficulty, as output by Bitcoin's getDifficulty.

Graphs 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).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.)See discussion in target.The minimum difficulty, when the target is at the maximum allowed value, is 1.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 each 10 minutes, 2016 blocks would take exactly two weeks to find.If the previous 2016 blocks took more than two weeks to find, the difficulty is reduced.If they took less than two weeks, the difficulty is increased.The change in difficulty is in proportion to the amount of time over or under two weeks the previous 2016 blocks took to find.To find a block, the hash must be less than the target.The hash is effectively a random number between 0 and 2**256-1.

The offset for difficulty 1 is and for difficulty D is The expected number of hashes we need to calculate to find a block with difficulty D is therefore or just The difficulty is set such that the previous 2016 blocks would have been found at the rate of one every 10 minutes, so we were calculating (D * 2**48 / 0xffff) hashes in 600 seconds.
xe bitcoin usdThat means the hash rate of the network was over the previous 2016 blocks.
xe bitcoin to usdCan be further simplified to without much loss of accuracy.
bitcoin pill reviewAt difficulty 1, that is around 7 Mhashes per second.
bitcoin satoshi to usdAt the time of writing, the difficulty is 22012.4941572, which means that over the previous set of 2016 blocks found the average network hash rate was (The eternal question.)
ethereum enabled websites

The average time to find a block can be approximated by calculating: 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.
bitcoin loan blockchainFor example, using Python we calculate the average time to generate a block using a 1Ghash/s mining rig when the difficulty is 20000: and find that it takes just under 24 hours on average.
bitcoin rigs for saleAny one grinding of the hash stands the same chance of "winning" as any other.
bitcoin ostThe numbers game is how many attempts your hardware can make per second.
quick bitcoin faucetYou need to know the difficulty (above) and your khash/sec rate (reported by the client).

Mining Hardware Comparison has some stats that may help you predict what you could get.Visit a calculator or perform the maths yourself, /bitcoin/calculator.php /bitcoincalculator.php /calculator /bitcoin-mining-calculator Remember it's just probability!There are no guarantees you will win every N days.Bitcoin Difficulty History What is Bitcoin Mining Difficulty?Bitcoin Sign up or log in to customize your list._ Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top up vote down vote favorite 6 Every 2016 blocks one needs to calculate new bits value.What is the formula to calculate it?protocol development block difficulty up vote down vote What does the bits field represent?First of all, we need to understand what the 'bits' field means.Bits is in 'compact' format.This is kind of like a floating point format, but it represents big integers rather than arbitrary real numbers.

The first byte indicates the number of bytes the represented number takes up, and the next one to three bytes give the most significant digits of the number.If the 2nd byte has a value greater than 127 then the number is interpreted as being negative.To convert a positive integer to 'compact' format, we: convert the integer into base 256. if the first (most significant) digit is greater than 127 (0x7f), prepend a zero digit the first byte of the 'compact' format is the number of digits in the above base 256 representation, including the prepended zero if it's present the following three bytes are the first three digits of the above representation.If less than three digits are present, then one or more of the last bytes of the compact representation will be zero.Example 1 - Convert 1000 to 'compact' format For example, to represent 1000 in 'compact' format, we convert to base 256: 1000 = (0x03)*256 + (0xe8)*1 So we have a 2 digit base 256 number: 03 e8 The first digit is not greater than 0x7f, so we don't prepend a zero digit: 03 e8 Then the compact representation becomes: 02 03 e8 00 Example 2 - Convert max target to 'compact' format The minimum difficulty has a target of 2^(256-32)-1.

Let's represent that in 'compact' format.First we convert it to base 256: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff That's 28 0xff digits.The first digit is greater than 0x7f, so we prepend a zero digit: 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff Now it's 29 digits long.So the 'compact' representation of this is: 1d 00 ff ff Notice we've lost a lot of 'ff' digits there.We've only kept 2 bytes of precision, what with the size byte and the prepended zero byte using up two of the four available bytes.If we were to convert back from 'compact' format to see what number we've actually stored, we get: ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 which is in fact the maximum target used by Bitcoin.This is what a difficulty of 1 sets the block hash target to be.How is the value of the bits field calculated?Now that we know what the bits field means, we can look at how its value is decided.

In the official client, the bits value is calculated by function GetNextWorkRequired() in src/main.cpp, which does the following: if we're working on a block that's a multiple of 2016 (every 2 weeks) look at the timestamps on the last block, and the block 2015 blocks before it calculate the difference in these two timestamps if the difference is greater than 8 weeks, set it to 8 weeks; this prevents the difficulty decreasing by more than a factor of 4 if the difference is less than half a week, set it to half a week; this prevents the difficulty increasing by more than a factor of 4 multiply the difference by the current target (ie.the current bits converted from 'compact' representation to the target it represents) divide the result by 2 weeks if the result is greater than the maximum target (2^(256-32)-1), set it to the maximum target convert the result to 'compact' form, and use that as the new bits value otherwise (we're working on a block that's NOT a multiple of 2016 if we're on testnet and it's later than 15 Feb 2012 if it's been more than 20 minutes since the last block was found set bits to its highest possible value, 0x1d00ffff, which represents a difficulty of 1; this is the 'special-min-difficulty rule' otherwise set bits to the same as in the last non-special-min-difficulty rule block otherwise (we're not on testnet, or it's before 15 Feb 2012) set bits to the same as in the last block up vote 3 down vote Here is the relevant code from main.cpp: static const int64 nTargetTimespan = 14 * 24 * 60 * 60; // two weeks static const int64 nTargetSpacing = 10 * 60; static const int64 nInterval = nTargetTimespan / nTargetSpacing; ... // Go back by what we want to be 14 days worth of blocks const CBlockIndex* pindexFirst = pindexLast; for (int i = 0; pindexFirst && i < nInterval-1; i++) pindexFirst = pindexFirst->pprev; assert(pindexFirst); // Limit adjustment step int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime(); printf(" nActualTimespan = %"PRI64d" before bounds
", nActualTimespan); if (nActualTimespan < nTargetTimespan/4) nActualTimespan = nTargetTimespan/4; if (nActualTimespan > nTargetTimespan*4) nActualTimespan = nTargetTimespan*4; // Retarget CBigNum bnNew; bnNew.SetCompact(pindexLast->nBits); bnNew *= nActualTimespan; bnNew /= nTargetTimespan; if (bnNew > bnProofOfWorkLimit) bnNew = bnProofOfWorkLimit; ... return bnNew.GetCompact(); So the important steps are: Translate the bits of block n+2015 to a BigNum target.

Calculate the timespan between blocks n and n+2015 (as an integer number of seconds).Multiply the old target by the timespan.Divide the result by the desired timespan 2 weeks = 1209600 seconds.This is integer arithmetic so it's rounded down.The result is the new target.Convert the target to bits.The code for the CBigNum class is at bignum.h.up vote 2 down vote i use the following python code to convert back and forth between "target" and "bits": import binascii def target_int2bits(target): # /a/2926/2116 # get in base 256 as a hex string target_hex = int2hex(target) bits = "00" if (hex2int(target_hex[: 2]) > 127) else "" bits += target_hex # append bits = hex2bin(bits) length = int2bin(len(bits), 1) # the bits value could be zero (0x00) so make sure it is at least 3 bytes bits += hex2bin("0000") # the bits value could be bigger than 3 bytes, so cut it down to size bits = bits[: 3] return length + bits def bits2target_int(bits_bytes): exp = bin2int(bits_bytes[: 1]) # exponent is the first byte mult = bin2int(bits_bytes[1:]) # multiplier is all but the first byte return mult * (2 ** (8 * (exp - 3))) def int2hex(intval): hex_str = hex(intval)[2:] if hex_str[-1] == "L": hex_str = hex_str[: -1] if len(hex_str) % 2: hex_str = "0" + hex_str return hex_str def hex2int(hex_str): return int(hex_str, 16) def hex2bin(hex_str): return binascii.a2b_hex(hex_str) def int2bin(val, pad_length = False): hexval = int2hex(val) if pad_length: # specified in bytes hexval = hexval.zfill(2 * pad_length) return hex2bin(hexval) def bin2hex(binary): # convert raw binary data to a hex string.