I understood that when a new transaction comes in, the miners have to start over, or at least change their merkle-tree to include the new transaction, essentially starting from scratch again.

If I look a the real-time transactions on https://blockchain.info/, how could miners ever make a block when there is never a break?

Unless you define a break as a few microseconds, and since every second you can calculate I believe billions of possible hashes, I still find it hard to grasp how a new block gets "chosen" or verified in human understandable terms.

  • Every new hash has equal probability of success, regardless of whether it's the first hash tried on a given block or whether there have been millions before. "Restarting" isn't a meaningful concept; you're effectively "restarting" billions of times a second anyway, so practically nothing is lost by updating the header with the new transaction. – Nate Eldredge Sep 8 '16 at 15:25
  • @NateEldredge Let's say you've tried a 1000 nonces without finding a block, so you know those 1000 nonces aren't it, at least for the current block. But if anything changes (ie the hash), then it has to start over in the sense that you don't have a 1000 known wrong nonces, but 0. But I think I understand your point that probability-wise there is not much of a difference. – BlockChange Sep 9 '16 at 11:46
  • Nope. I am saying there is zero difference. Knowing 1000 nonces that don't work is useless information; it has absolutely no bearing on the probability of the next nonce working. Note there is no guarantee that any nonce works at all; you could have tried all but one of the 2^32 possible nonces for a block, and the probability of the last one working is still the same as for the first one you tried: 1 in (difficulty * 2^32). (Indeed, for any given block, it's extremely unlikely that any of the 2^32 possible nonce values work.) – Nate Eldredge Sep 9 '16 at 11:54
  • Consider the following thought experiment. I have a red die with a billion sides. I roll it and ask you to guess the number. If you're right, you win. If not, I roll again and ask you guess the new number. Since we re-roll every time, having 1000 incorrect guesses doesn't help or hurt your chances on the next roll. And if after 1000 plays, I throw away the red die and start using a billion-sided green die, you haven't lost any "progress". – Nate Eldredge Sep 9 '16 at 11:56
  • If the nonce range is let's say 1-1000000 (I think there's an upper limit in bitcoin?) then you probability increases, per probability, if you know what I mean. I understand that it's possible that no nonce works at all, but then you are getting closer to using an extraNonce, or perhaps the difficulty decreasing? – BlockChange Sep 9 '16 at 11:57

Mining is computation based, but it's not constant, it's random. Essentially, every hash calculated generates a random number. If the random number is below the target, it's valid to create a block. The probability of any single hash being low enough is minuscule (you have a better chance of winning the lottery several times in a row), but that's why you need to calculate a lot of hashes. The actual merkle tree makes no difference as long as the tree itself is valid. Miners don't have any obligation to include all transactions in the mempool, so they typically will submit blocks whenever they find a valid hash.

So really, the updates to the merkle tree don't actually matter. In fact, it can be helpful since there are more nonces to try.

| improve this answer | |
  • Could you explain how it is helpful, and how it means more nonces to try? Preferably with an example. – BlockChange Sep 9 '16 at 11:42

Miners choose which transactions to include in their blocks. So they don't have to continually incorporate newly arrived transactions into the blocks they are trying. They can if they want, for example to take advantage of collecting possibly higher transaction fees associated with new transactions.

| improve this answer | |

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.