MCPcopy Create free account
hub / github.com/ElementsProject/elements / AssembleBlock

Function AssembleBlock

src/bench/block_assemble.cpp:18–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include <vector>
17
18static void AssembleBlock(benchmark::Bench& bench)
19{
20 const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
21
22 CScriptWitness witness;
23 witness.stack.push_back(WITNESS_STACK_ELEM_OP_TRUE);
24
25 // Collect some loose transactions that spend the coinbases of our mined blocks
26 constexpr size_t NUM_BLOCKS{200};
27 std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
28 for (size_t b{0}; b < NUM_BLOCKS; ++b) {
29 CMutableTransaction tx;
30 tx.vin.push_back(MineBlock(test_setup->m_node, P2WSH_OP_TRUE));
31 tx.witness.vtxinwit.resize(1);
32 tx.witness.vtxinwit.back().scriptWitness = witness;
33 tx.vout.emplace_back(CTxOut(CAsset(), 1337, P2WSH_OP_TRUE));
34 if (NUM_BLOCKS - b >= COINBASE_MATURITY)
35 txs.at(b) = MakeTransactionRef(tx);
36 }
37 {
38 LOCK(::cs_main);
39
40 for (const auto& txr : txs) {
41 const MempoolAcceptResult res = test_setup->m_node.chainman->ProcessTransaction(txr);
42 assert(res.m_result_type == MempoolAcceptResult::ResultType::VALID);
43 }
44 }
45
46 bench.run([&] {
47 PrepareBlock(test_setup->m_node, P2WSH_OP_TRUE);
48 });
49}
50
51BENCHMARK(AssembleBlock);

Callers

nothing calls this directly

Calls 10

MineBlockFunction · 0.85
CAssetClass · 0.85
PrepareBlockFunction · 0.85
emplace_backMethod · 0.80
ProcessTransactionMethod · 0.80
CTxOutClass · 0.50
MakeTransactionRefFunction · 0.50
push_backMethod · 0.45
resizeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected