Skip to content
Christopher Moore edited this page Jan 12, 2019 · 2 revisions

CPU Mining with Glyff

At current time and with the first release of Glyff private testnet, you'll need a) a CPU and b) an Glyff client, glyff-node. GPU mining is also available but not recommended with toy funds due to large electricity use.

At the moment, glyff-node only includes a CPU miner, but there are several GPU miners available.

When you start up your Glyff node with glyff it is not mining by default. To start it in mining mode, you use the --mine command line option. The -minerthreads parameter can be used to set the number parallel mining threads (defaulting to the total number of processor cores).

glyff --mine --minerthreads=4

You can also start and stop CPU mining at runtime using the console. miner.start takes an optional parameter for the number of miner threads.

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

In order to earn glyff you must have your coinbase address set. This coinbase defaults to your primary account. If you don't have a coinbase address, then glyff --mine will not start up.

You can set your coinbase on the command line:

glyff --coinbase 1 --mine  2>> glyff.log // 1 is index: second account by creation order OR
glyff --coinbase '0xa4d8e9cae4d04b093aac82e6cd355b6b963fb7ff' --mine 2>> glyff.log

You can reset your coinbase on the console too:

miner.setCoinbase(eth.accounts[2])

Note that your coinbase does not need to be an address of a local account, just an existing one.

You can check your hashrate with miner.hashrate, the result is in H/s (Hash operations per second).

> miner.hashrate
712000

After you successfully mined some blocks, you can check the ether balance of your coinbase account. Now assuming your coinbase is a local account:

> eth.getBalance(eth.coinbase).toNumber();
'34698870000000' 

In order to spend your earnings you will need to have this account unlocked.

> personal.unlockAccount(eth.coinbase)
Password
true

You can check which blocks are mined by a particular miner (address) with the following code snippet on the console:

function minedBlocks(lastn, addr) {
  addrs = [];
  if (!addr) {
    addr = eth.coinbase
  }
  limit = eth.blockNumber - lastn
  for (i = eth.blockNumber; i >= limit; i--) {
    if (eth.getBlock(i).miner == addr) {
      addrs.push(i)
    }
  }
  return addrs
}
// scans the last 1000 blocks and returns the blocknumbers of blocks mined by your coinbase 
// (more precisely blocks the mining reward for which is sent to your coinbase).   
minedBlocks(1000, eth.coinbase);
//[352708, 352655, 352559]

Note that it will happen often that you find a block yet it never makes it to the canonical chain. This means when you locally include your mined block, the current state will show the mining reward credited to your account, however, after a while, the better chain is discovered and we switch to a chain in which your block is not included and therefore no mining reward is credited. Therefore it is quite possible that as a miner monitoring their coinbase balance will find that it may fluctuate quite a bit.

GPU mining


Work in progress