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

Method CreateBlock

src/test/util/setup_common.cpp:444–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442}
443
444CBlock TestChain100Setup::CreateBlock(
445 const std::vector<CMutableTransaction>& txns,
446 const CScript& scriptPubKey)
447{
448 auto mining{interfaces::MakeMining(m_node)};
449 auto block_template{mining->createNewBlock({
450 .use_mempool = false,
451 .coinbase_output_script = scriptPubKey,
452 }, /*cooldown=*/false)};
453 Assert(block_template);
454 CBlock block{block_template->getBlock()};
455
456 Assert(block.vtx.size() == 1);
457 for (const CMutableTransaction& tx : txns) {
458 block.vtx.push_back(MakeTransactionRef(tx));
459 }
460 RegenerateCommitments(block, *Assert(m_node.chainman));
461
462 while (!CheckProofOfWork(block.GetHash(), block.nBits, m_node.chainman->GetConsensus())) ++block.nNonce;
463
464 return block;
465}
466
467CBlock TestChain100Setup::CreateAndProcessBlock(
468 const std::vector<CMutableTransaction>& txns,

Callers 3

CreateAndProcessBlockMethod · 0.95
BOOST_FIXTURE_TEST_CASEFunction · 0.45
CreateTestBlockFunction · 0.45

Calls 9

MakeMiningFunction · 0.85
MakeTransactionRefFunction · 0.85
RegenerateCommitmentsFunction · 0.85
CheckProofOfWorkFunction · 0.85
createNewBlockMethod · 0.80
getBlockMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected