2

I know my question might sound familiar to the question as follow: When does a miner decide to stop collecting transactions and start calculating hashes to try to win?

But actually, the reply marked as answer in that topic didn't answer the question: when will miners stop waiting/listening to new transactions?

According the answer in the link above, miners will start calculating nonce number but as far as I know, the nonce number is result of hash calculation of block header. Since the block header contains the hash of the merkle tree's root which is generated by all the transactions included in the block, so waiting and adding new transactions means the hash of the merkle tree's root will keep changing so how can miners determine to stop and concentrate in 'mining' the nonce from a stable source of transactions (or merkle tree's root hash)?

Let's simplify the questions by an example in case you cannot understand my language: miner A receives transaction a1 and then start calculating the nonce number for 1 minute (let's assume that in this period of time, there's no new transactions come and interrupt the process) but then a transaction a2 arrives, what will miner A do? Adding a2 into the candidate block, getting new hash of merkle tree's root and restarting to find the nonce number? Or just ignore the transaction a2? If A chooses to ignore new transactions to be included, can anybody tell me when it will do that (assume all of the transactions collected are not larger than the MAX_BLOCK_SIZE constant)?

Any replies or explainations for some of my questions are highly appreciated. Thank you!!

6

They were never "waiting" in the first place.

A miner is incrementing nonces and computing hashes continuously. As soon as a new transaction a2 arrives, it is added to the Merkle tree, the block header is regenerated, and hashing continues with the new block header.

It's misleading to call this a "restart", since that implies there was some progress that is being lost. Mining is progress-free. Each hash is an independent trial with equal probability to succeed, regardless of what the underlying block header is.

To emphasize this, suppose you have a block header h1 on which you have already tried a billion nonce values, and a header h2 which has just been generated and on which no nonces have been tried yet. If you have the choice as to which one to hash next, which should you choose, for the greatest chance of finding a winning nonce? The answer is, it makes no difference - they both have exactly the same probability. So there is no harm in switching to h2.

  • Thank you very much Nate for you answer! I have another question related to this: so every time a correct nonce number is found which helps to mine a new block and the process of creating new block starts again, the "variable" (if any) which represents the current trial nonce will be initialized to zero for the new round or it will keep the value where it has ended in the previous round? – hoanghs13 Nov 9 '16 at 6:46
  • 4
    It does not matter - all what matters is that the nonce changes. In fact, modern hardware mining boxes cycle through all nonces for a block candidate in under a millisecond, so they are continuously trying other variations in the block as well. – Pieter Wuille Nov 9 '16 at 8:52
  • 1
    @hoanghs13: I believe Bitcoin Core resets the nonce to zero. This happens to be convenient because it makes it easy to check when you have gone through all 2^32 nonce values for a particular block header. But there is nothing magical about this, and software that chose to start at a different value, or a random value, would work just the same. – Nate Eldredge Nov 9 '16 at 13:02
  • Typical modern mining hardware always tries all possible nonces. There's no point in wasting precious ASIC space on doing anything else. Essentially, the operation the ASIC performs efficiently is that of trying all 2^32 possible nonces. – David Schwartz Nov 9 '16 at 18:17

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.