[Ethereum] Geth Console – Sleep after mining a block

consolego-ethereumminingtesting

I am running a local testnet with a low mining difficulty to test my contracts, and I am conscious that when I start another mining geth instance the total computation will hog my CPU.

My question is – is there a way of making the geth miner sleep for a specified period of time before mining the next block?

I could just have one node mining transactions, but I would like to emulate the real network more closely.

I am sure there are other solutions to testnet mining that I am not aware of, and they are also welcomed.

Best Answer

You can write a JavaScript script that controls geth's behavior related to mining.

There is a simple script that mines only nonempty blocks on go-ethereum wiki. Another one is mine.js script from Embark Framework. This one is feature-rich and configurable for periodic mining, mining reward cap, number of mining threads and more (via glider).

Scripts are loaded with js command, for example:

geth --rpc js mining.js
Related Topic