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

Method CommitStaging

src/txgraph.cpp:2681–2719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2679}
2680
2681void TxGraphImpl::CommitStaging() noexcept
2682{
2683 // Staging must exist.
2684 Assume(m_staging_clusterset.has_value());
2685 Assume(m_main_chunkindex_observers == 0);
2686 // Get rid of removed transactions in staging before moving to main, so they do not need to be
2687 // added to the chunk index there. Doing so is impossible if they were unlinked, and thus have
2688 // no Ref anymore to pass to the fallback comparator.
2689 ApplyRemovals(/*up_to_level=*/1);
2690 // Delete all conflicting Clusters in main, to make place for moving the staging ones
2691 // there. All of these have been copied to staging in PullIn().
2692 auto conflicts = GetConflicts();
2693 for (Cluster* conflict : conflicts) {
2694 conflict->Clear(*this, /*level=*/0);
2695 DeleteCluster(*conflict, /*level=*/0);
2696 }
2697 // Mark the removed transactions as Missing (so the staging locator for these transactions
2698 // can be reused if another staging is created).
2699 for (auto idx : m_staging_clusterset->m_removed) {
2700 m_entries[idx].m_locator[1].SetMissing();
2701 }
2702 // Then move all Clusters in staging to main.
2703 for (int quality = 0; quality < int(QualityLevel::NONE); ++quality) {
2704 auto& stage_sets = m_staging_clusterset->m_clusters[quality];
2705 while (!stage_sets.empty()) {
2706 stage_sets.back()->MoveToMain(*this);
2707 }
2708 }
2709 // Move all statistics, precomputed data, and to-be-applied removals and dependencies.
2710 m_main_clusterset.m_deps_to_add = std::move(m_staging_clusterset->m_deps_to_add);
2711 m_main_clusterset.m_to_remove = std::move(m_staging_clusterset->m_to_remove);
2712 m_main_clusterset.m_group_data = std::move(m_staging_clusterset->m_group_data);
2713 m_main_clusterset.m_oversized = std::move(m_staging_clusterset->m_oversized);
2714 m_main_clusterset.m_txcount = std::move(m_staging_clusterset->m_txcount);
2715 m_main_clusterset.m_txcount_oversized = std::move(m_staging_clusterset->m_txcount_oversized);
2716 // Delete the old staging graph, after all its information was moved to main.
2717 m_staging_clusterset.reset();
2718 Compact();
2719}
2720
2721void GenericClusterImpl::SetFee(TxGraphImpl& graph, int level, DepGraphIndex idx, int64_t fee) noexcept
2722{

Callers 3

ApplyMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
FUZZ_TARGETFunction · 0.80

Calls 7

SetMissingMethod · 0.80
MoveToMainMethod · 0.80
has_valueMethod · 0.45
ClearMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
resetMethod · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.64
FUZZ_TARGETFunction · 0.64