3

When a bitcoin client sends a transaction to its connecting full nodes, before that transaction is confirmed, where is it stored? on all full nodes?

6

Full nodes keep a "mempool" of unconfirmed transactions, so yes, but every full node chooses its own rules for how many transactions it keeps in the mempool, e.g. minimum fee, maximum number of transactions, amount of time before the transactions drop out, etc. So not every full node keeps every unconfirmed transaction. If a node doesn't have a transaction in its mempool when a block is mined, it will just request that transaction.

| improve this answer | |
  • 1
    Thx, then different full nodes may keep different overlapping mempools? Also why does a full node request a transaction (not in its mempool) when a block (with the transaction) is mined, since at that time, the full node needs to store the newly mined block ( which includes that transaction ) anyway? – Smjohn Mar 30 '18 at 1:11
  • @Smjohn correct. And full nodes can get a list of transactions in the block without downloading all of them as it's more efficient than redownloading all of them again, they just request the missing ones – MeshCollider Mar 30 '18 at 7:36
  • I see, but a block is only 1 to 2M, downloading it all probably is more efficient than downloading a list of transactions and then checking against its own mempool, and assembling the block in terms of latency, isn't it? – Smjohn Mar 30 '18 at 13:03
  • @Smjohn I think the block stores just the transaction ID and not the whole transaction details, that's why it's much more efficient to request only the missing transaction than the entire list. – Deniz Aug 23 '18 at 8:09
1

The reply to your answer is: in the mempool.


What Is The Bitcoin Mempool?

The Bitcoin mempool is the pool of unconfirmed Bitcoin transactions on the Bitcoin network. Once a Bitcoin transaction happens on Bitcoin’s blockchain, it is not immediately added; instead, it goes into this pool of in-motion transactions.

Each running full node on the Bitcoin network is connected to this mempool. The miners, working at their respective nodes, collate a bunch of transactions from this mempool, and then they try to solve an energy-intensive math problem.

The collection of these transactions is called a “block”, and whichever miner first solves the math problem gets to add this block to Bitcoin’s blockchain. This is the first confirmation of that block.

So that is the mempool, but wait! There’s more to it…

The question is: how do certain transactions get picked out of the mempool before others?

Bitcoin’s block time is 10 minutes, but we all experience extreme delays from time to time in getting our transactions confirmed.

This happens because miners are not picking out our transactions from the mempool.

Miners win a lottery of 12.5 BTC every time they successfully mine a Bitcoin block. But apart from this fixed lottery of 12.5 BTC, miners also get a bonus amount of bitcoins for successfully mining a block. This bonus is called the “Bitcoin mining fee”.

So when a miner successfully mines a block, they get 12.5 BTC plus X amount of transaction fees, which is a cumulative sum of all the transaction fees in that block.

And that’s why it stands to reason that a miner will pick to mine the blocks in the mempool with higher transaction fees.

And this is the reason that our Bitcoin transactions sometimes get “stuck” in the mempool and are not picked up until several hours (maybe even days) later.

| improve this answer | |
  • Thx. But actually I am more wondering that a transaction with higher transaction fee will be picked by multiple miners, then if both blocks are mined, can the transaction appear in both blocks in the final chain? i.e., does final blockchain allow one transaction appear in multiple blocks? – Smjohn Mar 30 '18 at 13:07
  • Every miner while trying to resolve a block includes a list of transaction in the block, based on how much fees are included in each tx. The miner who find the block and broadcasts it to the network will consequently "confirm" all the txs which have been included in the block. If it happens that two miners are able to solve the same block at the same time, so that a double copy of each included txs is submitted to the network within the mined blocks by both of the miners, ONLY one block will be accepted from the network, i.e. the fastest to reach the more nodes possbile in the less time. – user51260 Mar 30 '18 at 13:13
  • Thx, I understand that part. But I guess my question was not clear enough : A miner can only pick an already formed block or it picks whatever transactions it likes to form a block? If the 1st case, then who forms blocks and what incentive for this task? If latter, then it is very possible that two miners are mining two different blocks but with some overlapping transactions. When one block is mined and added to the chain, another miner can keep mining the other block just with a different hash from the new block, this may result in two different but overlapping blocks in the chain. Correct? – Smjohn Mar 30 '18 at 13:36

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.