MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / generateBlocks

Function generateBlocks

src/rpc/mining.cpp:195–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195static UniValue generateBlocks(ChainstateManager& chainman, Mining& miner, const CScript& coinbase_output_script, int nGenerate, uint64_t nMaxTries)
196{
197 UniValue blockHashes(UniValue::VARR);
198 while (nGenerate > 0 && !chainman.m_interrupt) {
199 std::unique_ptr<BlockTemplate> block_template(miner.createNewBlock({ .coinbase_output_script = coinbase_output_script }, /*cooldown=*/false));
200 CHECK_NONFATAL(block_template);
201
202 std::shared_ptr<const CBlock> block_out;
203 if (!GenerateBlock(chainman, block_template->getBlock(), nMaxTries, block_out, /*process_new_block=*/true)) {
204 break;
205 }
206
207 if (block_out) {
208 --nGenerate;
209 blockHashes.push_back(block_out->GetHash().GetHex());
210 }
211 }
212 return blockHashes;
213}
214
215static bool getScriptFromDescriptor(std::string_view descriptor, CScript& script, std::string& error)
216{

Callers 2

generatetodescriptorFunction · 0.85
generatetoaddressFunction · 0.85

Calls 6

GenerateBlockFunction · 0.85
createNewBlockMethod · 0.80
getBlockMethod · 0.80
push_backMethod · 0.45
GetHexMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected