5

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?

1 Answer 1

3

Actually, that is exactly what happens, and it is the reason why synchronizing the block chain is so slow: we download all blocks, with all transaction history in it, and build and maintain an index that states which transaction output was spent or not, and even where it was spent.

As of 0.8, the reference client will switch to a new model where no such index is maintained anymore. Instead, it will maintain a copy of the set of transactions, but only with their not-yet-spent outputs, which is much smaller than the full data (around 150 MiB as of writing, december 10, 2012).

1
  • 1
    Thank you for detailed answer. Is there a commit or a file in github.com/bitcoin/bitcoin that shows current and/or new transation behavior?
    – wix
    Commented Dec 11, 2012 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.