1

I am a little confused about how I use the block template. I saw this question which leads me to think that perhaps I need to call this function until I get a hash that fits the difficulty. Basically what are the function calls I need to perform in order to mine a block template so I can then call submit block.

Sorry if this is a vague question I am just quite confused.

I have also seen this question but again it doesn't really answer what function I should call.

Just for more context I am calling monero from a bazel repository so things are a bit hairy and complex.

1 Answer 1

2

I am a little confused about how I use the block template... Basically what are the function calls I need to perform in order to mine a block template so I can then call submit block.

A block template is just that, a template for a block that a miner can perform work on (repeated hashing) to try and find a solution (a hash that meets the network difficulty) and then submit to the network.

So first a miner obtains a block template, typically using the daemon method get_block_template.

Next the miner relatedly updates the nonce space1 and performs a hash2 (using the RandomX hash function). If / when the resulting hash (which is just a number) meets the network difficulty, they can submit the block to the network using the daemon method submit_block.

Lastly, peer nodes validate that any proposed blocks hash meets the network difficulty. If no other miner submits a valid block (or chain of blocks) with more work done, after 60 blocks the miner gets paid the reward.

1 the nonce space can be any combination of the nonce field in the block header or in any reserved space of the miner transaction.

2 what actually gets hashed is a block hashing blob, which is a concatenation of the block header, a merkle root hash of the blocks transactions and a varint of the count of txs (src). A miner can either directly use the returned block hashing blob from get_block_template or they can construct the block hashing blob themselves using the block template blob. The latter is required if the miner is changing the reserved space of the miner tx.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.