<p>The difficulty calculation is part of the consensus rules that nodes on the network follow. It can be calculated at any time by a node and is calculated every 2016 blocks (two weeks, on average). When the correct number of blocks has passed, the node calculates it based on the last two weeks and adjusts in order to maintain a 10 minute block time (on average). The calculation is in <a href="https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49" rel="nofollow noreferrer">CalculateNextWorkRequired</a>.</p>

<p>Miners can request a block template from a node, in order to start mining, which contains the hash target (i.e. difficulty), see <a href="https://bitcoincore.org/en/doc/0.18.0/rpc/mining/getblocktemplate/" rel="nofollow noreferrer">getblocktemplate</a>.</p>

CC BY-SA 4.0
2019-09-20T21:32:00.393Z
2019-09-20T21:32:00.393Z
JBaczuk
<p>How are the requirements of the hash for mining a new block determined? Is it published or a message is sent?</p>

CC BY-SA 4.0
2019-09-23T12:48:58.043Z
I think this [reference](https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch10.asciidoc) is a good reading for undestend the mining
vincenzopalazzo
<hash>
How are the requirements of the hash for mining a new block determined?
user99550
# How are the requirements of the hash for mining a new block determined?

(Asked by: username_0 on 2019-09-20)

How are the requirements of the hash for mining a new block determined? Is it published or a message is sent?

**Tags:** hash

> **Comments:**
> **username_1**: I think this [reference](https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch10.asciidoc) is a good reading for undestend the mining  

---

## 1 answers

### Answer by username_2 on 2019-09-20. Score: 1

The difficulty calculation is part of the consensus rules that nodes on the network follow. It can be calculated at any time by a node and is calculated every 2016 blocks (two weeks, on average). When the correct number of blocks has passed, the node calculates it based on the last two weeks and adjusts in order to maintain a 10 minute block time (on average). The calculation is in [CalculateNextWorkRequired](https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49).

Miners can request a block template from a node, in order to start mining, which contains the hash target (i.e. difficulty), see [getblocktemplate](https://bitcoincore.org/en/doc/0.18.0/rpc/mining/getblocktemplate/).


---

