<p>The flow of a transaction is like this:</p>
<ul>
<li>Users create and submit transactions</li>
<li>Nodes gossip the transaction in the network, validating them, adding them to their mempools and forwarding them</li>
<li>Miners select transactions from their mempools to build block templates</li>
<li>A new block is found that includes the submitted transaction and the transaction is confirmed</li>
</ul>
<p>Miners mine continuously—each of them is always trying to find a new block. A block is found when a block header hashes to something that is lower than the difficulty target. There is no way to know whether a block header candidate is a valid block until it is hashed. Since every miner is trying to pay themselves the mining reward, they all have unique block templates (as their transactions don't match, the Merkle root of the transactions differs). This means that every miner is searching previously unseen block candidates and finding a new block essentially comes down to an independent random event with a minuscule chance for every block template. Sometimes it only takes seconds for a new block to be found, and sometimes it takes more than an hour. The difficulty retargets automatically to keep the expected block interval to about 10 minutes.</p>
<p>Miners continuously update their block templates whenever they hear about new transactions. As you said, they pick the transactions with the highest feerates, to build the block template that will collect the most fees.<br />
When miners hear about new blocks, they briefly use an empty block template that doesn't include any transactions. The miners do this to avoid including a transaction that the previous block already included which would make their new block be in conflict and invalid. As soon as the miners have processed the previous block, they build a new block template with transactions again and use that. So, we usually only see empty blocks if a new block is found seconds after a previous block, or if there are actually no transactions waiting to be confirmed.</p>

CC BY-SA 4.0
2022-03-07T15:20:03.477Z
Nice answer which changed my perspective :) But just a small question for clarification. U said, "miners do this to avoid including a transaction that the previous block already included which would make their new block be in conflict and invalid."
But why there are instead of just stopping the creation process and look new transactions there are creating new empty blocks? (For earn award?)
Murad Sofi
CC BY-SA 4.0
2022-03-07T15:23:22.290Z
And U said "or if there are actually no transactions waiting to be confirmed". if there are see new transactions not exist why instead of stoping there are creating an empty block? So let's say if in some blockchain not any transaction exist mining process will continue?
Murad Sofi
CC BY-SA 4.0
2022-03-07T15:33:49.317Z
The reward for mining a block is composed of two parts: the transaction fees, and an amount of new bitcoins to be created. The miners can still collect the new coins even if they do not include any transactions. Since the transaction fees are only a small part of the block reward right now, mining empty blocks is still very profitable.
Murch
CC BY-SA 4.0
2022-03-07T15:34:43.193Z
The miners don't know if they only saw a transaction after it was included in the previous block, therefore it just being new to them is insufficient for putting it in their block template. They have to finish processing the previous block to know which transactions can be safely included.
Murch
CC BY-SA 4.0
2022-03-07T14:40:00.190Z
2022-03-07T14:45:04.070Z
2022-03-07T14:45:04.070Z
Murch
<p>I'm a bit new to blockchain and I am trying to understand.</p>
<p>As I understand when a new transaction happens it's added to a mining pool and miners prioritize these transactions (for example by amount of fee) and select some transactions to add them to block (max 1MB).</p>
<p>But it's also possible for some block to be empty (without transactions).</p>
<p>So, if some blocks are empty, does this mean that new block creation starts at certain times? (Does it have some schedule like every 5 min or something like that?)</p>
<p>Or does something trigger miners to create a new block?</p>

CC BY-SA 4.0
2022-03-07T15:58:44.410Z
There hasn't been a 1MB block size limit for many years now. Since Segwit activated blocks have been bigger on average.
Jannes
<mining-pools><mining-theory><block>
When do miners add a new block to blockchain?
Murad Sofi
# When do miners add a new block to blockchain?

(Asked by: username_0 on 2022-03-07)

I'm a bit new to blockchain and I am trying to understand.

As I understand when a new transaction happens it's added to a mining pool and miners prioritize these transactions (for example by amount of fee) and select some transactions to add them to block (max 1MB).

But it's also possible for some block to be empty (without transactions).

So, if some blocks are empty, does this mean that new block creation starts at certain times? (Does it have some schedule like every 5 min or something like that?)

Or does something trigger miners to create a new block?

**Tags:** mining-pools, mining-theory, block

> **Comments:**
> **username_1**: There hasn't been a 1MB block size limit for many years now. Since Segwit activated blocks have been bigger on average.  

---

## 1 answers

### Answer by username_2 on 2022-03-07. Score: 3 | Accepted answer

The flow of a transaction is like this:

* Users create and submit transactions
* Nodes gossip the transaction in the network, validating them, adding them to their mempools and forwarding them
* Miners select transactions from their mempools to build block templates
* A new block is found that includes the submitted transaction and the transaction is confirmed

Miners mine continuously—each of them is always trying to find a new block. A block is found when a block header hashes to something that is lower than the difficulty target. There is no way to know whether a block header candidate is a valid block until it is hashed. Since every miner is trying to pay themselves the mining reward, they all have unique block templates (as their transactions don't match, the Merkle root of the transactions differs). This means that every miner is searching previously unseen block candidates and finding a new block essentially comes down to an independent random event with a minuscule chance for every block template. Sometimes it only takes seconds for a new block to be found, and sometimes it takes more than an hour. The difficulty retargets automatically to keep the expected block interval to about 10 minutes.

Miners continuously update their block templates whenever they hear about new transactions. As you said, they pick the transactions with the highest feerates, to build the block template that will collect the most fees.  
When miners hear about new blocks, they briefly use an empty block template that doesn't include any transactions. The miners do this to avoid including a transaction that the previous block already included which would make their new block be in conflict and invalid. As soon as the miners have processed the previous block, they build a new block template with transactions again and use that. So, we usually only see empty blocks if a new block is found seconds after a previous block, or if there are actually no transactions waiting to be confirmed.

> **Comments:**
> **username_0**: Nice answer which changed my perspective :) But just a small question for clarification. U said, "miners do this to avoid including a transaction that the previous block already included which would make their new block be in conflict and invalid." But why there are instead of just stopping the creation process and look new transactions there are creating new empty blocks? (For earn award?)  
> **username_0**: And U said "or if there are actually no transactions waiting to be confirmed". if there are see new transactions not exist why instead of stoping there are creating an empty block? So let's say if in some blockchain not any transaction exist mining process will continue?  
> **username_2**: The reward for mining a block is composed of two parts: the transaction fees, and an amount of new bitcoins to be created. The miners can still collect the new coins even if they do not include any transactions. Since the transaction fees are only a small part of the block reward right now, mining empty blocks is still very profitable.  
> **username_2**: The miners don't know if they only saw a transaction after it was included in the previous block, therefore it just being new to them is insufficient for putting it in their block template. They have to finish processing the previous block to know which transactions can be safely included.  

---

