I'm a hobbyist C++ programmer and spent some time going through Bitcoin's source code and absorbing whatever information I could find online about the protocol. I would really appreciate someone answering the few remaining questions I have.
1. How does the network decide when enough transactions have occurred for new block to be generated? Is it a hard-set number? On a related note, how do I know if I actually have all transactions in a given moment?
2. Once I successfully generate a block, how do I go about announcing this fact to the network? Is it a simple floodfill -- i.e., I send it to all my directly-connected neighbors, and they do the same, on and on until everyone gets it?
3. What happens if two people, Alice and Bob, generate a valid block at approximately the same time, and begin telling the network of their block simultaneously? Won't some nodes receive Alice's first, and some receive Bob's first? Who will ultimately be decided as the "winner"?
1. block is generated when somebody finds the solution to a hard mathematical problem (finding a hash of the last block's header below the current difficulty). transactions are confirmed as they get put into the blocks.
3. they compete to have their block accepted by the network. the blockchain gets forked until one gets ahead of the other. it's a race to have your generated block incorporated into somebody elses next block.