5

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

9

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.

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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