we have transactions on both blocks. What happens with the ones on the orphaned block?
Consider that there are two miners, Alice and Bob, and the last solved block was a block at height 100. So both are trying to solve for block 101. Bob may have some transactions that Alice doesn't yet include and vice-versa.
Then say both happen to solve a block 101 at about the same time and broadcast their 101 to their peers.
A peer node X happens to learn first of Alice's block 101. and any transactions in Alice's 101 will now show as 1/unconfirmed. Then X learns of Bob's block 101. X will still store that block (as a side branch) but will still treat Alice's block 101 as the last solved block. Any transactions that were added exclusively by Bob in his block 101 will still show as 0/unconfirmed by node X.
If another miner, Charlie, instead first learned of a block at height 101 from a peer relayed Bob's block 101, then it is trying to solve for block 102, Charlie solves it and broadcasts it and thus Charlie's peers propagate it and eventually it reaches X.
Now X confirms Charlie's 102 is valid and thus takes that side branch that included Bob's 101 and makes it the main branch after appending to it Charlie's block 102. Alice's 101 is now a side branch (which causes her 101 to be an orphan). If there were any transactions that Alice had shown as 1/unconfirmed in which neither Bob nor Charlie had added, then X will now display 0/unconfirmed for that transaction.
-
http://en.bitcoin.it/wiki/Protocol_rules#.22block.22_messagesSo to recap ... when X learned of Alice's block 101 first it added it as being valid, and any other blocks for 101 that arrived later (e.g., Bob's block 101) were added to a side branch. So the winner at any block height is the first valid block to arrive at each specific node. Thus there is an incentive to miners to see their blocks propagate as quickly as possible, and the smaller the block (fewer transactions) the faster it will be verified and relayed by each node. There are orphaned blocks pretty frequently (e.g. daily) so this isn't just some odd quirk that happens only once in a blue moon.