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

Function BuildTreeGraph

src/test/fuzz/cluster_linearize.cpp:365–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363 */
364template<typename BS>
365DepGraph<BS> BuildTreeGraph(const DepGraph<BS>& depgraph, uint8_t direction)
366{
367 DepGraph<BS> depgraph_tree;
368 for (DepGraphIndex i = 0; i < depgraph.PositionRange(); ++i) {
369 if (depgraph.Positions()[i]) {
370 depgraph_tree.AddTransaction(depgraph.FeeRate(i));
371 } else {
372 // For holes, add a dummy transaction which is deleted below, so that non-hole
373 // transactions retain their position.
374 depgraph_tree.AddTransaction(FeeFrac{});
375 }
376 }
377 depgraph_tree.RemoveTransactions(BS::Fill(depgraph.PositionRange()) - depgraph.Positions());
378
379 if (direction & 1) {
380 for (DepGraphIndex i : depgraph.Positions()) {
381 auto children = depgraph.GetReducedChildren(i);
382 if (children.Any()) {
383 depgraph_tree.AddDependencies(BS::Singleton(i), children.First());
384 }
385 }
386 } else {
387 for (DepGraphIndex i : depgraph.Positions()) {
388 auto parents = depgraph.GetReducedParents(i);
389 if (parents.Any()) {
390 depgraph_tree.AddDependencies(BS::Singleton(parents.First()), i);
391 }
392 }
393 }
394
395 return depgraph_tree;
396}
397
398} // namespace
399

Callers 1

FUZZ_TARGETFunction · 0.85

Calls 9

PositionRangeMethod · 0.80
FeeRateMethod · 0.80
RemoveTransactionsMethod · 0.80
GetReducedChildrenMethod · 0.80
GetReducedParentsMethod · 0.80
AddTransactionMethod · 0.45
AnyMethod · 0.45
AddDependenciesMethod · 0.45
FirstMethod · 0.45

Tested by

no test coverage detected