Author

Topic: Q: How removing transactions from mempool works (Read 1051 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
I see.

So if you receive a block that has a transaction in it that was not in your mempool but was included in the block, does that transaction get added to your mempool and then shortly removed once you finish validating the block?
No, that would be unnecessary.
newbie
Activity: 16
Merit: 7
I see.

So if you receive a block that has a transaction in it that was not in your mempool but was included in the block, does that transaction get added to your mempool and then shortly removed once you finish validating the block?

staff
Activity: 3458
Merit: 6793
Just writing some code
The mempool does not have a defined structure; it depends entirely on how you implement it. You can implement it poorly and have it be very inefficient, or implement it well and have it be very efficient.

The way that Bitcoin Core implements the mempool can be found here (along with a big comment describing what is going on): https://github.com/bitcoin/bitcoin/blob/86f7d5b69bb72b85d71c32329cc43e80897ce348/src/txmempool.h#L330
newbie
Activity: 16
Merit: 7
Hello!

Quick question: A block is solved and propagated through the network. When a node validates a block, it must remove the valid transactions out of its mempool.

Is this "removal" process a linear operation? Meaning if you need to remove 1000 txns included in the block from 14000 txns in your mempool, you need to search through worst case all 140000 txns?
Jump to: