<p>The answer for this is that miners need to have this in memory to consolidate tx for fee optimization and fast computation. Non mining /relay node can have mempool in disk. See <a href="https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2015-July/009479.html" rel="nofollow">reference</a></p>

<p>The only concern for a relay node is to prevent  DOS attack during relay of transactions which also can be prevented by bandwidth limits.</p>

CC BY-SA 3.0
2016-04-27T06:31:27.273Z
2016-04-27T06:39:16.877Z
2016-04-27T06:39:16.877Z
dark knight
<p>A large part of those transactions only needs to be kept for a limited time, in the order of 10 minutes. Once transactions are in a block they are removed from the mempool and the whole block is written to disk.</p>

<p>However while the transactions are in memory they are actually consulted quite often. For every newly incoming transactions checks need to be done to see for example whether it conflicts with any of the existing transactions or whether it's a child or parent to an already existing one.</p>

<p>Writing and reading them from disk will cause quite a bit of overhead. Which is actually important not just because it's a bit of overhead. For example it might open up DOS attacks where hostile nodes can create patterns of transactions that maximise reading and writing disk.</p>

<p>Also for transaction and block propagation speeds it is important that transactions are validated as quickly as possible.</p>

<p>Another point is that the amount of memory used by the mempool isn't actually huge anyway. Work is being done on better filtering of which transactions are allowed into the mempool in the first place (minimum fees and Child Pays for Parent etc.). As well as expunging older and/or low fee or otherwise lower interest transactions out when the mempool nears full.</p>

CC BY-SA 3.0
2015-11-26T23:39:55.920Z
2015-11-27T10:27:17.777Z
2015-11-27T10:27:17.777Z
Jannes
<p>Why does Bitcoin keep (unconfirmed) transactions in a memory pool? What would happen if these were stored on disk instead?</p>

<transactions><mempool>
Why does Bitcoin keep transactions in a memory pool?
webdevelopersdiary
# Why does Bitcoin keep transactions in a memory pool?

(Asked by: username_0 on 2015-11-26)

Why does Bitcoin keep (unconfirmed) transactions in a memory pool? What would happen if these were stored on disk instead?

**Tags:** transactions, mempool


---

## 2 answers

### Answer by username_2 on 2015-11-26. Score: 9 | Accepted answer

A large part of those transactions only needs to be kept for a limited time, in the order of 10 minutes. Once transactions are in a block they are removed from the mempool and the whole block is written to disk.

However while the transactions are in memory they are actually consulted quite often. For every newly incoming transactions checks need to be done to see for example whether it conflicts with any of the existing transactions or whether it's a child or parent to an already existing one.

Writing and reading them from disk will cause quite a bit of overhead. Which is actually important not just because it's a bit of overhead. For example it might open up DOS attacks where hostile nodes can create patterns of transactions that maximise reading and writing disk.

Also for transaction and block propagation speeds it is important that transactions are validated as quickly as possible.

Another point is that the amount of memory used by the mempool isn't actually huge anyway. Work is being done on better filtering of which transactions are allowed into the mempool in the first place (minimum fees and Child Pays for Parent etc.). As well as expunging older and/or low fee or otherwise lower interest transactions out when the mempool nears full.


---

### Answer by username_1 on 2016-04-27. Score: 1

The answer for this is that miners need to have this in memory to consolidate tx for fee optimization and fast computation. Non mining /relay node can have mempool in disk. See [reference](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2015-July/009479.html)

The only concern for a relay node is to prevent DOS attack during relay of transactions which also can be prevented by bandwidth limits.


---

