## Bitcoin regtest mining

2

I wonder if I can do mining with Bitcoin-0.16.1 in regtest mode, just for simulating mainnet situation where there are new blocks coming in constantly.

I am aware that I can use generate to generate blocks almost instantly after every transaction and thus confirm the transaction. But can I use a miner program to automate that process and simulate better the real-world situation, i.e. new block coming in constantly in small number?

I have tried cgminer connecting to my regtest solo mining but it does not seem to mine anything, it just sits there and hash rate is always 0. Any advice on how I can mine on regtest or should I set up some automated scripts to call generate from time to time?

3

You can build your miner with a bash command:

\$ while true; do bitcoin-cli -regtest generate 1; sleep 300; done


You'l get a block every 5'. If you want a better simulation of mainnet you could use a rndom sleep

oh yes I discovered later this is probably a more efficient way to simulate actual mining on regtest than using a mining program – tbraden – 2018-11-08T13:52:21.043

1

I am answering my own question for those who run into the same situation and for the sake of knowledge sharing.

YES you can mine on a regtest network. The difficulty of mining on regtest is extremely low that you miner program will just mine block after block almost instantly.

The reason why cgminer was not mining is because it is for GPU mining and there was no GPU on my machine and I could not find a way to mine with CPU using cgminer.

So I switched to another miner: cpuminer, which mines with cpu and it worked:)