<blockquote>
  <p>Now my question is, we hash the previous block chain's hash with transactions and the nonce? </p>
</blockquote>

<p><a href="http://blockexplorer.com/rawblock/000000000000000488a3d3bc1d92cf44ca868650cbce012e05570cb226b4ad65" rel="nofollow">We can look at the form of a block here.</a> </p>

<p>The information that is actually hashed include the version, previous block hash, the merkle root of the transactions the miner has included in the block, the current time, the target difficulty of the block, and the 32bit nonce. The rest of the information here is infered. </p>

<p>There's more information about the block format on <a href="https://en.bitcoin.it/wiki/Block_hashing_algorithm" rel="nofollow">the wiki.</a> </p>

<blockquote>
  <p>Furthermore, if the first try is not successful the nonce is changed as a result to compute a new hash?</p>
</blockquote>

<p>The nonce is incremented until the 32bit space is exhausted, at which point the header is modified to give a different work for the miner. At the present time this may happen many times a second.  </p>

<blockquote>
  <p>If we start adding transactions to a block and another block is created before our block, what happens to our work?</p>
</blockquote>

<p>The current work is discarded, and the miner starts working on top of the highest block the know about. </p>

<blockquote>
  <p>Moreover, can we include blocks with 0 transactions to the block chain?</p>
</blockquote>

<p>No, a block must contain one transaction containing the miners reward, which can be any value up the limit of the current block reward, at the time of writing this is 25BTC. 1 transaction blocks are quite common, as they're less likely to be orphaned (another is created while the minted block is making it's way across the network). </p>

CC BY-SA 3.0
2013-12-06T01:34:48.570Z
2013-12-06T01:34:48.570Z
Anonymous
<p>Yes, the nonce is increased each attempt.  I may be pedantic, but the hash is a double SHA256 hash, eg SHA256(SHA256(data))</p>

<p>Take a look at <a href="http://blockexplorer.com/rawblock/000000000000026190ebd9560f94b8d0534c6cd6fd585bf6fdb54610e6b676c3" rel="nofollow">http://blockexplorer.com/rawblock/000000000000026190ebd9560f94b8d0534c6cd6fd585bf6fdb54610e6b676c3</a> to see an example of a raw (successfully mined block) showing the header information.</p>

<p>Note that if you overflow (get to the top count) the nonce, you simply alter the timestamp or add new transactions and you can reset your nonce back to 0.</p>

<p>Also, it is computationally impossible for miners in different pools to come up with the same merkle root as the block </p>

<blockquote>
  <p>If we start adding transactions to a block and another block is created before our block, what happens to our work?</p>
</blockquote>

<p>Your work is lost/wasted and everyone starts mining the next block (which includes the hash of the block before it).</p>

<blockquote>
  <p>Can we include blocks with 0 transactions to the block chain?</p>
</blockquote>

<p>Yes you can, but you will be throwing away the block reward of (currently) 25BTC as one of the transactions in the block is the one claiming the reward.</p>

CC BY-SA 3.0
2013-12-06T01:43:05.563Z
2013-12-06T01:43:05.563Z
John
<p>I am studying the bitcoin internals and especially the proof-of-work. The proof-of-work is based on the mathematical problem that we have to compute from an input that produces a hash with a certain leading substring, I think the substring should start with a certain amount of zeroes.</p>

<p>We hash the current input with SHA-256 so we need to compute 2^256. Now my question is, we hash the previous block chain's hash with transactions and the nonce? Is it anything else including in the hash? Furthermore, if the first try is not successful the nonce is changed as a result to compute a new hash?</p>

<p>A few more questions: 
a) If we start adding transactions to a block and another block is created before our block, what happens to our work? We start mining from the beginning or we continue mining with our remaining transactions?
b) Moreover, can we include blocks with 0 transactions to the block chain?</p>

<proof-of-work><mining-technical-details><empty-blocks>
What happens to a miner's work when they restart?
angel limneos
# What happens to a miner's work when they restart?

(Asked by: username_0 on 2013-12-06)

I am studying the bitcoin internals and especially the proof-of-work. The proof-of-work is based on the mathematical problem that we have to compute from an input that produces a hash with a certain leading substring, I think the substring should start with a certain amount of zeroes.

We hash the current input with SHA-256 so we need to compute 2^256. Now my question is, we hash the previous block chain's hash with transactions and the nonce? Is it anything else including in the hash? Furthermore, if the first try is not successful the nonce is changed as a result to compute a new hash?

A few more questions:
a) If we start adding transactions to a block and another block is created before our block, what happens to our work? We start mining from the beginning or we continue mining with our remaining transactions?
b) Moreover, can we include blocks with 0 transactions to the block chain?

**Tags:** proof-of-work, mining-technical-details, empty-blocks


---

## 2 answers

### Answer by username_1 on 2013-12-06. Score: 2

> Now my question is, we hash the previous block chain's hash with transactions and the nonce?

[We can look at the form of a block here.](http://blockexplorer.com/rawblock/000000000000000488a3d3bc1d92cf44ca868650cbce012e05570cb226b4ad65)

The information that is actually hashed include the version, previous block hash, the merkle root of the transactions the miner has included in the block, the current time, the target difficulty of the block, and the 32bit nonce. The rest of the information here is infered.

There's more information about the block format on [the wiki.](https://en.bitcoin.it/wiki/Block_hashing_algorithm)

> Furthermore, if the first try is not successful the nonce is changed as a result to compute a new hash?

The nonce is incremented until the 32bit space is exhausted, at which point the header is modified to give a different work for the miner. At the present time this may happen many times a second.

> If we start adding transactions to a block and another block is created before our block, what happens to our work?

The current work is discarded, and the miner starts working on top of the highest block the know about.

> Moreover, can we include blocks with 0 transactions to the block chain?

No, a block must contain one transaction containing the miners reward, which can be any value up the limit of the current block reward, at the time of writing this is 25BTC. 1 transaction blocks are quite common, as they're less likely to be orphaned (another is created while the minted block is making it's way across the network).


---

### Answer by username_2 on 2013-12-06. Score: 1

Yes, the nonce is increased each attempt. I may be pedantic, but the hash is a double SHA256 hash, eg SHA256(SHA256(data))

Take a look at <http://blockexplorer.com/rawblock/000000000000026190ebd9560f94b8d0534c6cd6fd585bf6fdb54610e6b676c3> to see an example of a raw (successfully mined block) showing the header information.

Note that if you overflow (get to the top count) the nonce, you simply alter the timestamp or add new transactions and you can reset your nonce back to 0.

Also, it is computationally impossible for miners in different pools to come up with the same merkle root as the block

> If we start adding transactions to a block and another block is created before our block, what happens to our work?

Your work is lost/wasted and everyone starts mining the next block (which includes the hash of the block before it).

> Can we include blocks with 0 transactions to the block chain?

Yes you can, but you will be throwing away the block reward of (currently) 25BTC as one of the transactions in the block is the one claiming the reward.


---

