I have a question about practical implementation of one part of Bitcoin protocol.
I'm reading the Protocol Rules for Bitcoin - "tx" messages and point 14 states that "For each input, if the referenced output has already been spent by a transaction in the main branch, reject this transaction".
How does the client validate that output has not been spent? It seems that it should remember all transations and amount of Bitcoins for all known addresses. This would take a lot of memory to store them all. Is there an optimization I'm not aware of?