'What happens when multiple blocks are added at the same time to a blockchain?
I understand that something called a ‘fork’ occurs when two blocks are formed at the same time. As I managed to gather from googling, this means that two separate blockchains are created.
Wikipedia describes "fork" as "what happens when a blockchain diverges into two potential paths forward", it mentions several different types of forks and explains that:
"Accidental fork happens when two or more miners find a block at nearly the same time. The fork is resolved when subsequent block(s) are added and one of the chains becomes longer than the alternative(s). The network abandons the blocks that are not in the longest chain (they are called orphaned blocks)."
Skipping all the different fork types (accidental, intentional, hard, soft,...), what actually happens in case of a "race condition"? Which block is added first? How is the problem resolved? If two chains are created, how are they later combined? Is one block simply abandoned?
Solution 1:[1]
Skipping all the different fork types (accidental, intentional, hard, soft,...), what actually happens in case of a "race condition"? Which block is added first? How is the problem resolved? If two chains are created, how are they later combined? Is one block simply abandoned?
Miners are always switching chains to attempt to work on the longest blockchain as this will likely be the main chain and result in higher rewards. Occasionally, like you pointed out two competing chains will fork off and they will be like this until one chain becomes longer resulting in the miners switching to this chain and the abandoned chain becoming an orphaned block.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Joshua Duxbury |

