It sounds like you're questioning timing and flow control and maybe thinking about mining delays and so on.
There's a delay to mine a transaction, but you don't need to consider that delay inside a transaction because transactions always execute or fail completely.
Your address.send()
returns a true/false success/failure result to your contract. You can safely think about that as happening immediately. It will log an event if the send()
succeeded, or nothing will happen if the send()
failed, because (throw
).
There's no time delay between the send()
and the event because each new block presents an internally consistent picture of the accepted transactions and the results.
Step-by-step:
- Someone sends a transaction to a function
- Miners run the contract and discover if it succeeds or fails. If it succeeds, what changed? There was a value transfer and an event.
- If the transaction succeeded, it gets included in a block and the state changes are part of the blockchain.
- If it failed (
throw
), miners ignore the transaction and there will be no state changes.
Hope it helps.