Author

Topic: Different transactions in different blocks? (Read 1118 times)

newbie
Activity: 9
Merit: 2
Thanks, You answered all my questions clearly, many thanks for your clear illustration.
legendary
Activity: 3472
Merit: 4801
now i get it, so how miners figure out this problem? I mean how they can make sure that they are not mining a transaction which is mined before?

Miners (or mining pools) keep track of the current list of unspent transaction outputs (UTXO), and the list of current unconfirmed transactions.

Whenever a miner (or pool) hears about a new transaction, it checks to make sure that all the inputs to the transaction are in the UTXO.  If there are any inputs that are not in the UTXO, then the transaction is invalid and is rejected.  This means that a miner (or pool) will only keep the first transaction that it hears about with any given transaction input.  Whenever a valid transaction is received, the miner (or pool) removes the transaction's inputs from their UTXO.  Whenever a transaction is dropped from the memory pool, the inputs of that dropped transaction are added back into the UTXO.

The miner selects the transactions for their block from their list of unconfirmed transactions.  Most other miners (or pools) will be selecting the same transactions for their own blocks.  Then all the miners (and pools) on the entire network attempt to complete the proof-of-work.  Once a miner (or pool) is successful in completing their block, they broadcast it to the network.  As each miner (or pool) receives the block, they verify that it is valid.  If it is not, then they reject it and continue working on their own block. If the block is valid, then they remove all the transactions that are in the block from their own list of unconfirmed transactions (and all the inputs that are in the block from their own UTXO). Then they build a new block with the transactions that remain in their memory pool and continue their proof-of-work with the new block that they've just created.

Occasionally, two miners (or pools) will broadcast a solved block at nearly the same time.  Each node on the network will use whichever of the two block it receives first, and the other block will be rejected as invalid. The entire network will be split as to which block they believe is the "real" block.  Eventually a miner will solve the next block on top of whichever block they thought was the "real" one.  Since their chain will now be 1 block longer than the competing chain, it will "win".  All the miners, pools, and nodes on that had been working on top of the other block will abandon it.  They will add all the transactions from their old block back to their memory pool, and all the inputs back to their UTXO. They'll then update their UTXO and memory pool based on the two block they receive from the now longer chain.  The abandoned block is commonly called an "orphaned" block.
legendary
Activity: 3668
Merit: 6382
Looking for campaign manager? Contact icopress!
now i get it, so how miners figure out this problem? I mean how they can make sure that they are not mining a transaction which is mined before?

When a block is mined, there is some sort of "winner block", that one and only one will be added to the block chain, that one will be referred by the next block. If the transaction is there, it's fine, else it will have to wait until it's included into a "winner" block.

If different miners decide for a different "winner" block, then a FORK is made. That's rather unusual and rather soon the wrong fork is discarded.


Edit: the next post is better explained
legendary
Activity: 4542
Merit: 3393
Vile Vixen and Miss Bitcointalk 2021-2023
Because each block refers to hash of the previous one (that's what makes it a blockchain), miners must download and (hopefully) verify the latest block before they can mine the next one. (There's been at least one case where a mining pool decided to skip the verification step (for speed) and lost a huge amount a money by unknowingly mining invalid blocks.)
newbie
Activity: 9
Merit: 2
now i get it, so how miners figure out this problem? I mean how they can make sure that they are not mining a transaction which is mined before?
legendary
Activity: 4542
Merit: 3393
Vile Vixen and Miss Bitcointalk 2021-2023
Multiple transactions with the same inputs is the very definition of double spending and is not allowed, regardless of all other factors. This includes multiple copies of the same transaction. This is also why identical transactions are only possible for coinbase transactions: they can't have the same inputs because they don't have inputs in the first place.
newbie
Activity: 9
Merit: 2

But miners listen to network and capture received transactions to their block, what if two miners capture the same block (which is possible) and then mine it in different blocks? its not double spending since its one unique transaction, input and output are the same not different.
legendary
Activity: 4542
Merit: 3393
Vile Vixen and Miss Bitcointalk 2021-2023
It's not clear what you're asking, but if you're if you're asking if it's possible for the same transaction to be in two or more blocks, this is not possible for normal transactions, since the same bitcoins cannot be spent twice (blocks which include transactions doing so are invalid and will be rejected by all nodes).

This does not apply to coinbase transactions (which generate new bitcoins instead of spending existing ones) - different blocks can have (and, indeed, have had) identical coinbase transactions, which is a problem since only one of them can ever be spent, for the above reason. Miners lose money if they erroneously produce such transactions.
newbie
Activity: 9
Merit: 2
Hi


As you know, different miners may try to mine blocks in blockchain, and it is possible that one transaction being added to different blocks. How blockchain face with this problem? In other world, is it possible that one transaction be in two or more blocks? if not, how other miners find out that their transactions are stored in blockchain?
Jump to: