Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
72

The Bitcoin difficulty started at 1 (and can never go below that). Then for every 2016 blocks that are found, the timestamps of the blocks are compared to find out how much time it took to find 2016 blocks, call it T. We want 2016 blocks to take 2 weeks, so if T is different, we multiply the difficulty by (2 weeks / T) - this way, if the hashrate continues ...


49

The bitcoin network rules define which difficulty each block has. This is done through a simple formula that only depends on the block chain itself. This means that if you give me a blockchain with blocks 1 through N, I can tell you with 100% accuracy what the difficulty of block N+1 will need to be, and I can reject any block which has the wrong difficulty. ...


40

if in the coming years the difficulty increases so much that mining is no longer profitable That's not really possible. The mining power is set so that the miners need 10 minutes in average to mine a block. If 50% of the miners would disappear because it's not profitable any more, the difficulty would decrease so that it's profitable again. Can the ...


25

There's a factor called Difficulty, the more hashing power exists on the network the more difficulty exists, therefore it's harder to mine coins. Right now The difficulty factor would let you recover your money fast because almost no one has ASIC chips, when they ship in bulk the difficulty factor will rise to 30-120 million during the year. To know by how ...


22

The explanations on the web are all very vague and mystical, on purpose maybe. Here is my take in simple words, just reading the megacoin source code from the above comment. The goal is to have a more adaptive way of adjusting the difficulty instead of just averaging the last 2016 blocks like bitcoin. This is needed because of multipools which might switch ...


21

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 ...


19

Difficulty is basically a different representation of the target to make it easier for normal humans to understand it. Difficulty represents how difficult the current target makes it to find a block, relative to how difficult it would be at the highest possible target (highest target=lowest difficulty). The current difficulty of 6,695,826 means that at a ...


16

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 ...


15

(If I may repeat myself a bit...) Mining is like having a lot of people throwing weighted coins (such that 1 millionth of the time it comes up heads) and telling you when they hit a heads. If one such "heads" is reported every 10 minutes (600 seconds), you can make a very accurate estimation of how many times per second the coins are being flipped. In this ...


13

Not if you don't have one already. The trouble is that you don't know when you'll receive your device and, as @user3418 says, the difficulty will be rising in the meantime. Butterfly Labs (who manufactures the device you're talking about) has only just started delivering devices, and already has a large number of pre-orders. You probably wouldn't receive ...


13

How to calculate the target from bits Let's start with a block-header, always 80-bytes that looks like this: 04000000b9e2784a84e5d2468cee60ad14e08d0fee5dda49a37148040000000000000000e9dd2b13157508891880ef68729a1e5ecdde58062ebfa214a89f0141e5a4717faefd2b577627061880564bec From the 80-bytes, the bits are actually the 72nd to 76th byte: ...


12

If you look at the network hash rate, you'll notice that it fell off after the Bitcoin exchange rate dropped. This leads to the conclusion that price drives difficulty. A drop in price caused a drop in difficulty. I have noticed this same correlation on another occasion; about two months ago. Also, the reverse is probably true. When the price soared to $30+...


12

Meni's answer is good. I just want to give some practical detail method about difficulty calculation, perhaps helpful for future views of this question's answer. Let's take a look at Satoshi's genesis block header (part of related info): $ bitcoin-cli getblockhash 0 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f $ bitcoin-cli ...


12

The target section of the block header is called nBits in the code. nBits is a 32-bit compact encoding of a 256-bit target threshold. It works like scientific notation, except that it uses base-256 instead of base-10. For example, if nBits is equal to 0x181b8330, you would calculate it like this: Or, more simply, you'd use the same shorthand you use with ...


11

The difficulty never changes by more than a factor of 4 (except for in a special case that only applies on testnet). The code that enforces this is here.


11

Each individual client checks the validity of each block it receives. If it receives an invalid block, it ignores that block as if it didn't exist. If you mine a block and other clients ignore it, you don't get your 50 Bitcoins. You only get to keep your 50 Bitcoins if the block you mined becomes a link in the accepted public chain. One of the first things ...


11

Difficulty is simply the ratio between the max target and the current target. It's easier to speak in terms of difficulty than in terms of the target. The max target is defined as (2^16 - 1) * 2^208 or approximately 2^224. Since there are 2^256 different values a hash can take, a random hash has a chance of about 2^(-32) to be lower than the max target. It ...


11

I'm not sure it was. When the network started operating (and Satoshi was pretty much the only one mining), blocks weren't found every 10 minutes. For example, the first 2016 blocks were found in 24 days rather than 2 weeks. Normally this would cause the target to go up but it can't go above the hardcoded max target, so only in block 32256 in December 30 2009 ...


11

A hash is 256 bits long, so there are 2^256 possible hashes in the hash space. But if you assert that the hash has to begin with a 0, that halves the number of hashes that are allowed (and thus doubles the average number of hashes you need to test), and if you say it must start with two 0's, that's now only quarter of the hash space that is valid. The ...


10

The ALU OP numbers are correct. The numbers vary based on the video card but are basically in the range of 1,300 to 1,700 operations per double-hash. On the x86, you need more instructions (around 3,700 - 4,500 depending on the exact CPU) but these CPUs can average more than one operation per clock cycle, so you can't convert instruction counts directly into ...


10

A supercomputer is way slower than mining with ASICs. A supercomputer only has much CPU power, not even GPU power and ASICs are way more powerfull than GPUs. ASICs represent the hashing algorithm as hardware which means they can't do anything else, that's why they are so fast. At http://bitcoinwatch.com/ you can see the current network hashrate in PetaFLOPS,...


10

Mining is a self-adjusting system. The difficulty only rises in accordance to the available mining power. Hence, it can neither go to a difficulty where it will take months for a block to be found, nor can it become prohibitely expensive to mine. Also see How is difficulty calculated?.


9

Changing these 2 lines gets what you want. Note that it's quick and dirty and will break non-testnet, so don't use this for anything but testnet: diff --git a/src/main.cpp b/src/main.cpp index a9311e2..b3496a1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -780,7 +780,7 @@ int64 static GetBlockValue(int nHeight, int64 nFees) } static const int64 ...


9

Well, you can TRY mining. To see how much coins you can expect, check your computer's GPU on the Wiki page, get its hash rate, and plug that into a profitability calculator, such as mine. This can give you an idea of how many coins can you expect to mine and whether you would get any profit from that. Unfortunately, most likely you won't be able to mine at ...


9

Hashes are 256-bit integers, meaning they are whole numbers between 0 and 115792089237316195423570985008687907853269984665640564039457584007913129639935. There are no infinitely many different hashes. In particular, the number of hashes smaller than the target is exactly equal to the target. In any case, Cantor's diagonal has nothing to do with it - if ...


9

The simple answer: no. The not to simple answer: extremely unlikely. Miners hash an input block, in the hopes of getting a result that satisfies the difficulty requirement, i.e., has a certain number of zeroes in front. Now the possibilities for the miner to vary the input are quite large. There is the 4 byte nonce, there is the order transactions are put ...


9

The Bitcoin reward schedule follows a predetermined pattern, see Controlled supply from the Bitcoin wiki. The next reward drop will happen at block number 420000. The current block number at the time of writing this answer is 318662. There are about 101338 blocks remaining. At approximately 10 minutes per block, there are approximately 1008 blocks per week, ...


9

You're presenting it as a choice between either allowing miners to choose the difficulty, or having it be implied by previous history. In fact, neither is true. The target is determined by history (for the reasons you bring up), and the target stored inside the block header has to match the value determined by history. At this point, there is no good ...


9

17 judging by the latest blocks published on blockchain.info: https://blockchain.info/block/0000000000000000057fcc708cf0130d95e27c5819203e9f967ac56e4df598ee


9

Because blocks were not being mined in less than 10 minutes on average during this time (so the difficulty would only decrease and not increase), and the difficulty cannot go lower than 1.


Only top voted, non community-wiki answers of a minimum length are eligible