MCPcopy Create free account
hub / github.com/ElementsProject/lightning / clean_topo

Function clean_topo

devtools/clean_topo.c:22–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22void clean_topo(struct gossmap *map, bool remove_singles)
23{
24 struct gossmap_node *n, *next;
25 bool *visited;
26
27 /* Remove channels which are not enabled in both dirs. */
28 for (struct gossmap_chan *c = gossmap_first_chan(map);
29 c;
30 c = gossmap_next_chan(map, c)) {
31 if (!c->half[0].enabled || !c->half[1].enabled) {
32 gossmap_remove_chan(map, c);
33 }
34 }
35
36 if (remove_singles) {
37 for (n = gossmap_first_node(map); n; n = next) {
38 next = gossmap_next_node(map, n);
39 if (n->num_chans == 1)
40 gossmap_remove_node(map, n);
41 }
42 }
43
44 /* Remove isolated nodes (we assume first isn't isolated!) */
45 visited = tal_arrz(NULL, bool, gossmap_max_node_idx(map));
46 visit(map, gossmap_first_node(map), visited);
47
48 for (n = gossmap_first_node(map); n; n = next) {
49 next = gossmap_next_node(map, n);
50 if (!visited[gossmap_node_idx(map, n)])
51 gossmap_remove_node(map, n);
52 }
53 tal_free(visited);
54}

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 10

gossmap_first_chanFunction · 0.85
gossmap_next_chanFunction · 0.85
gossmap_remove_chanFunction · 0.85
gossmap_first_nodeFunction · 0.85
gossmap_next_nodeFunction · 0.85
gossmap_remove_nodeFunction · 0.85
gossmap_max_node_idxFunction · 0.85
gossmap_node_idxFunction · 0.85
tal_freeFunction · 0.85
visitFunction · 0.70

Tested by

no test coverage detected