<p>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.</p>

<p>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).</p>

CC BY-SA 3.0
2012-12-11T09:27:27.073Z
Thank you for detailed answer. Is there a commit or a file in https://github.com/bitcoin/bitcoin that shows current and/or new transation behavior?
wix
CC BY-SA 3.0
2012-12-10T21:42:01.910Z
2012-12-10T21:42:01.910Z
Pieter Wuille
<p>I have a question about practical implementation of one part of Bitcoin protocol.</p>

<p>I'm reading the <a href="https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages">Protocol Rules for Bitcoin - "tx" messages</a> 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".</p>

<p>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?</p>

<transactions>
Verifying transation inputs
wix
# Verifying transation inputs

(Asked by: username_0 on 2012-12-10)

I have a question about practical implementation of one part of Bitcoin protocol.

I'm reading the [Protocol Rules for Bitcoin - "tx" messages](https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_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?

**Tags:** transactions


---

## 1 answers

### Answer by username_1 on 2012-12-10. Score: 3 | Accepted answer

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).

> **Comments:**
> **username_0**: Thank you for detailed answer. Is there a commit or a file in https://github.com/bitcoin/bitcoin that shows current and/or new transation behavior?  

---

