If all transactions are broadcast to all nodes, and all nodes are mining these transactions into blocks. When a block is created and the block is broadcast to all nodes, it may contain transactions that other nodes are currently trying to put into their blocks.....what happens in this scenario?
-
They waste time mining until they get the newest block. This time lag, or rather, attempts to lessen it by not validating before mining on top of it, is what caused the last network split. Generally it's only a few seconds and 2 miners rarely find blocks at the same time. If they do, then the chain splits until one side finds the next block fastest, and everyone moves there and orphans the competing chain.– Luke MlsnaOct 31, 2017 at 16:51
-
1@Luke Mlsna please post answers as answers rather than comments :)– meshcolliderOct 31, 2017 at 19:25
-
1@LukeMlsna .... so, if a new block comes in, does a miner stop mining their current block? ....and start on a new block with new transactions?– Shamus HarkinNov 4, 2017 at 21:39
-
Yes, they immediately drop what they are doing and start mining on top of the newest block. Because any time spent mining a stale block is wasted.– Luke MlsnaNov 4, 2017 at 21:44
1 Answer
Not all blocks are mining the same transactions in their respective proofs-of-work. Each miner collects enough transactions via gossip until they reach the block size limit. Not all transactions will make it into a certain block, so those will be more likely candidates to make it into the next block. Miners decide which transactions to include in a block with the following equation:
priority = sum(input_value_in_base_units * input_age)/size_in_bytes