Expand description
Internal mining in Zebra.
§TODO
- pause mining if we have no peers, like
zcashd
does, and add a developer config that mines regardless of how many peers we have. https://github.com/zcash/zcash/blob/6fdd9f1b81d3b228326c9826fa10696fc516444b/src/miner.cpp#L865-L880 - move common code into zebra-chain or zebra-node-services and remove the RPC dependency.
Constants§
- BLOCK_
MINING_ WAIT_ TIME - How long we wait after mining a block, before expecting a new template.
- BLOCK_
TEMPLATE_ REFRESH_ LIMIT - A rate-limit for block template refreshes.
- BLOCK_
TEMPLATE_ WAIT_ TIME - The amount of time we wait between block template retries.
Functions§
- generate_
block_ templates - Generates block templates using
rpc
, and sends them to mining threads usingtemplate_sender
. - init
- Initialize the miner based on its config.
- mine_
a_ block - Mines one or more blocks based on
template
. Calculates equihash solutions, checks difficulty, and returns as soon as it has at least one block. Uses a different nonce range for eachsolver_id
. - run_
mining_ solver - Runs a single mining thread that gets blocks from the
template_receiver
, calculates equihash solutions with nonces based onsolver_id
, and submits valid blocks to Zebra’s block validator. - spawn_
init - Initialize the miner based on its config, and spawn a task for it.