I'm sure I am missing something trivial here but I have a question.
Let's say there are Node A and Node B. We send a transaction to both nodes. Both nodes now contain an unconfirmed transaction in their local mempool.
Node A includes the transaction in the next block with a successful solution. Node B accepts the new block from Node A and continues the chain by creating another new block, including the transaction it received earlier in that next block.
So we have a situation where Node A included the transaction in the first block and Node B included the transaction in the second block. How is this prevented?
I am aware of double spending but the resources I have read usually talk about the same transaction being included in the next block of both nodes but, in that case, one of the blocks would just be discarded.
Thanks.