Testnet Mining – High CPU Usage in Testnet Mining

go-ethereumminingtestnets

I have a private testnet set up on my local machine:

geth --rpc --rpcaddr "localhost" --rpcport "8545" --dev --mine --datadir="~/Library/Ethereum_dev" --rpccorsdomain="http://localhost" console 2>>geth.log

It's working great.

However, I'm on a MacBook Pro 2010 which is 5.5 years old now. Geth is eating one of my CPUs and I only have two.

I tried to use nice to suppress CPU usage:

nice -n 19 geth --rpc --rpcaddr "localhost" --rpcport "8545" --dev --mine --datadir="~/Library/Ethereum_dev" --rpccorsdomain="http://localhost" console 2>>geth.log

But I'm still using way too much for my liking. Does anyone have any ideas?

Best Answer

The --mine flag using your CPU power to generate testnet blocks.

Add the --minerthreads "1" flag to limit the mining to a single core, like that:

geth --rpc --rpcaddr "localhost" --rpcport "8545" --dev --mine --minerthreads "1" --datadir="~/Library/Ethereum_dev" --rpccorsdomain="http://localhost" console 2>>geth.log

You can also control the miner from the geth console:

> miner.stop()
true
> miner.start(1)
true

... where the number is the number of threads used by the miner. You dont have to keep the miner running all the time. Just start or stop it when ever you need it to create blocks for the transaction verification.

Related Topic