| 3189 | } |
| 3190 | |
| 3191 | std::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 | |
| 3220 | BlockBuilderImpl::BlockBuilderImpl(TxGraphImpl& graph) noexcept : m_graph(&graph) |
| 3221 | { |