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

Method GetCurrentChunk

src/txgraph.cpp:3191–3218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3189}
3190
3191std::optional<std::pair<std::vector<TxGraph::Ref*>, FeePerWeight>> BlockBuilderImpl::GetCurrentChunk() noexcept
3192{
3193 std::optional<std::pair<std::vector<TxGraph::Ref*>, FeePerWeight>> ret;
3194 // Populate the return value if we are not done.
3195 if (m_cur_iter != m_graph->m_main_chunkindex.end()) {
3196 ret.emplace();
3197 const auto& chunk_data = *m_cur_iter;
3198 const auto& chunk_end_entry = m_graph->m_entries[chunk_data.m_graph_index];
3199 if (chunk_data.m_chunk_count == LinearizationIndex(-1)) {
3200 // Special case in case just a single transaction remains, avoiding the need to
3201 // dispatch to and dereference Cluster.
3202 ret->first.resize(1);
3203 Assume(chunk_end_entry.m_ref != nullptr);
3204 ret->first[0] = chunk_end_entry.m_ref;
3205 m_known_end_of_cluster = true;
3206 } else {
3207 Assume(m_cur_cluster);
3208 ret->first.resize(chunk_data.m_chunk_count);
3209 auto start_pos = chunk_end_entry.m_main_lin_index + 1 - chunk_data.m_chunk_count;
3210 m_known_end_of_cluster = m_cur_cluster->GetClusterRefs(*m_graph, ret->first, start_pos);
3211 // If the chunk size was 1 and at end of cluster, then the special case above should
3212 // have been used.
3213 Assume(!m_known_end_of_cluster || chunk_data.m_chunk_count > 1);
3214 }
3215 ret->second = chunk_end_entry.m_main_chunk_feerate;
3216 }
3217 return ret;
3218}
3219
3220BlockBuilderImpl::BlockBuilderImpl(TxGraphImpl& graph) noexcept : m_graph(&graph)
3221{

Callers 3

BOOST_AUTO_TEST_CASEFunction · 0.80
FUZZ_TARGETFunction · 0.80

Calls 4

emplaceMethod · 0.80
GetClusterRefsMethod · 0.80
endMethod · 0.45
resizeMethod · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.64
FUZZ_TARGETFunction · 0.64