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

Method Merge

src/txgraph.cpp:1521–1551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1519}
1520
1521void GenericClusterImpl::Merge(TxGraphImpl& graph, int level, Cluster& other) noexcept
1522{
1523 /** Vector to store the positions in this Cluster for each position in other. */
1524 std::vector<DepGraphIndex> remap(other.GetDepGraphIndexRange());
1525 // Iterate over all transactions in the other Cluster (the one being absorbed).
1526 other.ExtractTransactions([&](DepGraphIndex pos, GraphIndex idx, FeePerWeight feerate) noexcept {
1527 // Copy the transaction into this Cluster, and remember its position.
1528 auto new_pos = m_depgraph.AddTransaction(feerate);
1529 // Since this cluster must have been made hole-free before being merged into, all added
1530 // transactions should appear at the end.
1531 Assume(new_pos == m_mapping.size());
1532 remap[pos] = new_pos;
1533 m_mapping.push_back(idx);
1534 m_linearization.push_back(new_pos);
1535 }, [&](DepGraphIndex pos, GraphIndex idx, SetType other_parents) noexcept {
1536 // Copy the transaction's dependencies, translating them using remap.
1537 SetType parents;
1538 for (auto par : other_parents) {
1539 parents.Set(remap[par]);
1540 }
1541 m_depgraph.AddDependencies(parents, remap[pos]);
1542 // Update the transaction's Locator. There is no need to call Updated() to update chunk
1543 // feerates, as Updated() will be invoked by Cluster::ApplyDependencies on the resulting
1544 // merged Cluster later anyway.
1545 auto& entry = graph.m_entries[idx];
1546 // Discard any potential ChunkData prior to modifying the Cluster (as that could
1547 // invalidate its ordering).
1548 if (level == 0) graph.ClearChunkData(entry);
1549 entry.m_locator[level].SetPresent(this, remap[pos]);
1550 });
1551}
1552
1553void SingletonClusterImpl::Merge(TxGraphImpl&, int, Cluster&) noexcept
1554{

Callers

nothing calls this directly

Calls 15

ExtractTransactionsMethod · 0.80
ClearChunkDataMethod · 0.80
SetPresentMethod · 0.80
TotalMemoryUsageMethod · 0.80
GetDepGraphIndexRangeMethod · 0.45
AddTransactionMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
SetMethod · 0.45
AddDependenciesMethod · 0.45
emptyMethod · 0.45
GetTxCountMethod · 0.45

Tested by

no test coverage detected