<p>Part of your misconception is this: "when a certain number of transactions are reached".  Mining doesn't need any particular number of transactions; it's legal to have a block with no transactions at all (except for the "coinbase" block reward transaction).  The "hash race" is always going on; it doesn't start and stop.  When a miner gets a new transaction, they just include it with the  transactions they already have, generate a new block header, and continue hashing on the new header.  There is no requirement that all miners be working with the same set of transactions.</p>

CC BY-SA 3.0
2016-05-06T13:58:26.893Z
2016-05-06T13:58:26.893Z
Nate Eldredge
<p>A miner begins creating a new block as soon as it receives a valid block from another miner.  It then begins to construct and hash the next block on top of the block it just received.</p>

<p>You were correct when you thought that each miner has a separate block from the rest.  Don't look at it as if miners are all cooperating to find a hash for the same block, but rather are competing against each other to make <em>their own</em> block the next in the chain.  If they find a valid block, they broadcast it, and other miners give up their efforts, and instead focus their hashing power on the next block.</p>

CC BY-SA 3.0
2016-05-06T13:56:48.130Z
Alright... So for example transactions a, b, c and d have been submitted to miner M1; transactions c, d, e, f and g have been submitted to miner M2. Both M1 and M2 are on head BC1. M1 finds a legit hash and announces the new blockchain BC2. Now what about M2? Current BC2 does not contain e, f and g. M2 might start a new block candidate B3, but this will cause transactions c and d to be duplicates. M2's ex-block B2' cannot be completely dropped either, that would cause e, f and g to vanish.
corsel
CC BY-SA 3.0
2016-05-06T13:59:38.820Z
@corsel: M2 generates a new block header B4 that contains transactions `e,f,g` only, and starts looking for a matching nonce for it.
Nate Eldredge
CC BY-SA 3.0
2016-05-06T14:03:37.407Z
Ah, so the blockchain is always in sync and are to be validated by majority of network, whereas block candidates are local and at the miners' will completely... If a malicious blockchain appears, it will be tested and rejected by other miners, or trying to manipulate history by hashing in deep levels fails, as in less time, a new chain will be announced.
corsel
CC BY-SA 3.0
2016-05-06T13:47:16.573Z
2016-05-06T13:47:16.573Z
Jestin
<p>I have been trying to understand the protocol and reading related documents, there is a point where i get stuck. </p>

<p>As far as i understand (correct me if not), when a transaction occurs, it is broadcast to the network and some miners receive it. When a certain number of transactions is reached, they are packed in a block and hash race begins.</p>

<p>What i fail to understand is; in this scheme, don't all the miners have to be in perfect memory coherence and time sync, so that they know when a block is to be sealed and start to iterate for hashes? Or do they not need to mine and hash the same global block, but have separate blocks which are later validated by other miners and interblock transaction collisions don't matter?</p>

<p>I know i misunderstand a very basic point in the protocol, but i can't figure what.</p>

CC BY-SA 3.0
2016-05-06T15:57:05.923Z
Related: [When does a miner decide to stop collecting transactions and start calculating hashes to try to win?](http://bitcoin.stackexchange.com/q/40398/5406)
Murch
<blockchain><protocol><block>
How does each miner know when to create a block?
corsel
# How does each miner know when to create a block?

(Asked by: username_0 on 2016-05-06)

I have been trying to understand the protocol and reading related documents, there is a point where i get stuck.

As far as i understand (correct me if not), when a transaction occurs, it is broadcast to the network and some miners receive it. When a certain number of transactions is reached, they are packed in a block and hash race begins.

What i fail to understand is; in this scheme, don't all the miners have to be in perfect memory coherence and time sync, so that they know when a block is to be sealed and start to iterate for hashes? Or do they not need to mine and hash the same global block, but have separate blocks which are later validated by other miners and interblock transaction collisions don't matter?

I know i misunderstand a very basic point in the protocol, but i can't figure what.

**Tags:** blockchain, protocol, block

> **Comments:**
> **username_1**: Related: [When does a miner decide to stop collecting transactions and start calculating hashes to try to win?](http://bitcoin.stackexchange.com/q/40398/5406)  

---

## 2 answers

### Answer by username_3 on 2016-05-06. Score: 4 | Accepted answer

A miner begins creating a new block as soon as it receives a valid block from another miner. It then begins to construct and hash the next block on top of the block it just received.

You were correct when you thought that each miner has a separate block from the rest. Don't look at it as if miners are all cooperating to find a hash for the same block, but rather are competing against each other to make *their own* block the next in the chain. If they find a valid block, they broadcast it, and other miners give up their efforts, and instead focus their hashing power on the next block.

> **Comments:**
> **username_0**: Alright... So for example transactions a, b, c and d have been submitted to miner M1; transactions c, d, e, f and g have been submitted to miner M2. Both M1 and M2 are on head BC1. M1 finds a legit hash and announces the new blockchain BC2. Now what about M2? Current BC2 does not contain e, f and g. M2 might start a new block candidate B3, but this will cause transactions c and d to be duplicates. M2's ex-block B2' cannot be completely dropped either, that would cause e, f and g to vanish.  
> **username_2**: @username_0: M2 generates a new block header B4 that contains transactions `e,f,g` only, and starts looking for a matching nonce for it.  
> **username_0**: Ah, so the blockchain is always in sync and are to be validated by majority of network, whereas block candidates are local and at the miners' will completely... If a malicious blockchain appears, it will be tested and rejected by other miners, or trying to manipulate history by hashing in deep levels fails, as in less time, a new chain will be announced.  

---

### Answer by username_2 on 2016-05-06. Score: 2

Part of your misconception is this: "when a certain number of transactions are reached". Mining doesn't need any particular number of transactions; it's legal to have a block with no transactions at all (except for the "coinbase" block reward transaction). The "hash race" is always going on; it doesn't start and stop. When a miner gets a new transaction, they just include it with the transactions they already have, generate a new block header, and continue hashing on the new header. There is no requirement that all miners be working with the same set of transactions.


---

