1
Let's say that 2 miners were able to add a block around the same time. However, when they broadcast their respective blocks to the network, other nodes receive these blocks in arbitrary order. The block that arrives later will be considered invalid because the hash of the previous block will not match up.
How does blockchain ensure that the newly block added is the same one for all the nodes?
EDIT:
Even if everyone is connected to the network this can happen:
Blocks A and B are added at the same time. Then next round C happens on top of A, and D happens on top of B. All nodes will delete the shortest block-tip before they even hear about the other broadcast.
node 1:
chain +A +C
chain +B +D
node 2:
chain +B +D
chain +A +C
And if this keeps happening, all the nodes will maintain different versions of the blockchain which, in their view is the correct version
node 1:
chain+A+C+...
node 2:
chain+B+D+...
i think i've answered a similiar question: https://bitcoin.stackexchange.com/questions/61106/does-full-node-store-all-valid-forks-and-alternative-blocks-from-blockchain-hi. I hope this is helpful.
– renlord – 2017-10-22T12:16:41.293:) yes, this is the question I refer to in my comment below – croraf – 2017-10-22T12:32:56.377
because I cannot add a comment on the other question...
It could might as well be that different nodes end up adding a block to a different block-tip and if that's the case how can consensus ever be reached – tushar – 2017-10-22T12:32:58.847
It can be, but highly unlikely if they are connected to the network. One of the branches will get ahead and broadcast its length and branch. Then everybody will switch to this longer branch. – croraf – 2017-10-22T12:46:43.043
I edited the question otherwise it would be too big for a comment. – tushar – 2017-10-22T12:58:53.270
As per how I understand, as soon as C comes, node 2 will switch to chain+A+C, and they will be consistent again. Or if D comes first, both will switch to chain+B+D. It is extremely unlikely this can continue for more than 1 block. – croraf – 2017-10-22T13:28:40.090
but I'm saying that node 2 never hears about C, but hears about D which happens on top of B – tushar – 2017-10-22T13:29:42.527
Let us continue this discussion in chat.
– croraf – 2017-10-22T13:30:02.517