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

Function AssembleBlock

src/bench/block_assemble.cpp:25–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23using node::BlockCreateOptions;
24
25static void AssembleBlock(benchmark::Bench& bench)
26{
27 const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
28
29 CScriptWitness witness;
30 witness.stack.push_back(WITNESS_STACK_ELEM_OP_TRUE);
31 BlockCreateOptions options{
32 .coinbase_output_script = P2WSH_OP_TRUE,
33 };
34
35 // Collect some loose transactions that spend the coinbases of our mined blocks
36 constexpr size_t NUM_BLOCKS{200};
37 std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
38 for (size_t b{0}; b < NUM_BLOCKS; ++b) {
39 CMutableTransaction tx;
40 tx.vin.emplace_back(MineBlock(test_setup->m_node, options));
41 tx.vin.back().scriptWitness = witness;
42 tx.vout.emplace_back(1337, P2WSH_OP_TRUE);
43 if (NUM_BLOCKS - b >= COINBASE_MATURITY)
44 txs.at(b) = MakeTransactionRef(tx);
45 }
46 {
47 LOCK(::cs_main);
48
49 for (const auto& txr : txs) {
50 const MempoolAcceptResult res = test_setup->m_node.chainman->ProcessTransaction(txr);
51 assert(res.m_result_type == MempoolAcceptResult::ResultType::VALID);
52 }
53 }
54
55 bench.run([&] {
56 PrepareBlock(test_setup->m_node, options);
57 });
58}
59static void BlockAssemblerAddPackageTxns(benchmark::Bench& bench)
60{
61 FastRandomContext det_rand{true};

Callers

nothing calls this directly

Calls 9

MineBlockFunction · 0.85
MakeTransactionRefFunction · 0.85
PrepareBlockFunction · 0.85
ProcessTransactionMethod · 0.80
push_backMethod · 0.45
emplace_backMethod · 0.45
backMethod · 0.45
atMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected