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

Method ApplyDependencies

src/txgraph.cpp:1559–1593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1557}
1558
1559void GenericClusterImpl::ApplyDependencies(TxGraphImpl& graph, int level, std::span<std::pair<GraphIndex, GraphIndex>> to_apply) noexcept
1560{
1561 // Sort the list of dependencies to apply by child, so those can be applied in batch.
1562 std::ranges::sort(to_apply, [](auto& a, auto& b) { return a.second < b.second; });
1563 // Iterate over groups of to-be-added dependencies with the same child.
1564 auto it = to_apply.begin();
1565 while (it != to_apply.end()) {
1566 auto& first_child = graph.m_entries[it->second].m_locator[level];
1567 const auto child_idx = first_child.index;
1568 // Iterate over all to-be-added dependencies within that same child, gather the relevant
1569 // parents.
1570 SetType parents;
1571 while (it != to_apply.end()) {
1572 auto& child = graph.m_entries[it->second].m_locator[level];
1573 auto& parent = graph.m_entries[it->first].m_locator[level];
1574 Assume(child.cluster == this && parent.cluster == this);
1575 if (child.index != child_idx) break;
1576 parents.Set(parent.index);
1577 ++it;
1578 }
1579 // Push all dependencies to the underlying DepGraph. Note that this is O(N) in the size of
1580 // the cluster, regardless of the number of parents being added, so batching them together
1581 // has a performance benefit.
1582 m_depgraph.AddDependencies(parents, child_idx);
1583 }
1584
1585 // Finally set the cluster to NEEDS_FIX, so its linearization is fixed the next time it is
1586 // attempted to be made ACCEPTABLE.
1587 Assume(!NeedsSplitting());
1588 Assume(!IsOversized());
1589 graph.SetClusterQuality(level, m_quality, m_setindex, QualityLevel::NEEDS_FIX);
1590
1591 // Finally push the changes to graph.m_entries.
1592 Updated(graph, /*level=*/level, /*rename=*/false);
1593}
1594
1595void SingletonClusterImpl::ApplyDependencies(TxGraphImpl&, int, std::span<std::pair<GraphIndex, GraphIndex>>) noexcept
1596{

Callers

nothing calls this directly

Calls 10

SetClusterQualityMethod · 0.80
GetLevelMethod · 0.80
IsPresentMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
SetMethod · 0.45
AddDependenciesMethod · 0.45
has_valueMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected