<p>It worked. I needed to change some configurations.</p>

<ul>
<li>change source code</li>
</ul>

<pre><code>// src/chainparams.cpp
consensus.nPowTargetTimespan = 14 * 24 * 60;
consensus.nPowTargetSpacing = 10; // 14 * 24 * 60 / 10 = 2016
consensus.fPowNoRetargeting = false;
</code></pre>

<p><a href="https://github.com/bitcoin/bitcoin/blob/0.17/src/chainparams.cpp#L291" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/0.17/src/chainparams.cpp#L291</a></p>

<ul>
<li>check the difficulty change</li>
</ul>

<pre><code>// initial difficulty
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest getmininginfo
{
  "blocks": 0,
  "currentblockweight": 0,
  "currentblocktx": 0,
  "difficulty": 4.656542373906925e-10,
  "networkhashps": 0,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}

// generate 2016 blocks
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest generate 2016

// check the difficulty
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest getmininginfo
{
  "blocks": 2016,
  "currentblockweight": 4000,
  "currentblocktx": 0,
  "difficulty": 4.716464207201856e-06,
  "networkhashps": 1024.75,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}
</code></pre>

CC BY-SA 4.0
2019-02-13T14:07:46.400Z
2019-02-13T14:07:46.400Z
zono
<p>I want to see the automated mining difficulty change on regtest but it did not change even I generated 2016 blocks. How can I see it?</p>

<pre><code>// initial difficulty
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest getmininginfo
{
  "blocks": 0,
  "currentblockweight": 0,
  "currentblocktx": 0,
  "difficulty": 4.656542373906925e-10,
  "networkhashps": 0,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}

// generate 2016 blocks
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest generate 2016

// show the difficulty
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest getmininginfo
{
  "blocks": 2016,
  "currentblockweight": 4000,
  "currentblocktx": 0,
  "difficulty": 4.656542373906925e-10,
  "networkhashps": 12,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}

// generate 2016 blocks again
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest generate 2016

// the difficulty was not changed
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest getmininginfo
{
  "blocks": 4032,
  "currentblockweight": 4000,
  "currentblocktx": 0,
  "difficulty": 4.656542373906925e-10,
  "networkhashps": 12,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}
</code></pre>

CC BY-SA 4.0
2019-02-11T07:09:17.637Z
There’s effectively no difficulty. That would defeat the purpose quite a lot.
Claris
CC BY-SA 4.0
2019-02-11T07:29:53.150Z
Thanks. Do you mean that there is no way to change the difficulty? I want to see the retargeting process even I change the source code. I'm trying to debug around the process. e.g https://github.com/bitcoin/bitcoin/blob/master/src/chainparams.cpp#L285
zono
<bitcoin-core><difficulty><difficulty-retargetting>
mining difficulty is not changed on regtest
zono
# mining difficulty is not changed on regtest

(Asked by: username_0 on 2019-02-11)

I want to see the automated mining difficulty change on regtest but it did not change even I generated 2016 blocks. How can I see it?
// initial difficulty
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest getmininginfo
{
  "blocks": 0,
  "currentblockweight": 0,
  "currentblocktx": 0,
  "difficulty": 4.656542373906925e-10,
  "networkhashps": 0,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}

// generate 2016 blocks
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest generate 2016

// show the difficulty
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest getmininginfo
{
  "blocks": 2016,
  "currentblockweight": 4000,
  "currentblocktx": 0,
  "difficulty": 4.656542373906925e-10,
  "networkhashps": 12,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}

// generate 2016 blocks again
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest generate 2016

// the difficulty was not changed
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest getmininginfo
{
  "blocks": 4032,
  "currentblockweight": 4000,
  "currentblocktx": 0,
  "difficulty": 4.656542373906925e-10,
  "networkhashps": 12,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}

**Tags:** bitcoin-core, difficulty, difficulty-retargetting

> **Comments:**
> **username_1**: There’s effectively no difficulty. That would defeat the purpose quite a lot.  
> **username_0**: Thanks. Do you mean that there is no way to change the difficulty? I want to see the retargeting process even I change the source code. I'm trying to debug around the process. e.g https://github.com/bitcoin/bitcoin/blob/master/src/chainparams.cpp#L285  

---

## 1 answers

### Answer by username_0 on 2019-02-13. Score: 1

It worked. I needed to change some configurations.

change source code

// src/chainparams.cpp
consensus.nPowTargetTimespan = 14 * 24 * 60;
consensus.nPowTargetSpacing = 10; // 14 * 24 * 60 / 10 = 2016
consensus.fPowNoRetargeting = false;

https://github.com/bitcoin/bitcoin/blob/0.17/src/chainparams.cpp#L291

check the difficulty change

// initial difficulty
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest getmininginfo
{
  "blocks": 0,
  "currentblockweight": 0,
  "currentblocktx": 0,
  "difficulty": 4.656542373906925e-10,
  "networkhashps": 0,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}

// generate 2016 blocks
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest generate 2016

// check the difficulty
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest getmininginfo
{
  "blocks": 2016,
  "currentblockweight": 4000,
  "currentblocktx": 0,
  "difficulty": 4.716464207201856e-06,
  "networkhashps": 1024.75,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}


---

