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

Function mkheap

common/dijkstra.c:72–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72static const struct gossmap_node **mkheap(const tal_t *ctx,
73 struct dijkstra *dij,
74 const struct gossmap *map,
75 const struct gossmap_node *start,
76 struct amount_msat sent)
77{
78 const struct gossmap_node *n, **heap;
79 size_t i;
80
81 heap = tal_arr(tmpctx, const struct gossmap_node *,
82 gossmap_num_nodes(map));
83 for (i = 1, n = gossmap_first_node(map);
84 n;
85 n = gossmap_next_node(map, n), i++) {
86 struct dijkstra *d = get_dijkstra(dij, map, n);
87 if (n == start) {
88 /* First entry in heap is start, distance 0 */
89 heap[0] = start;
90 d->heapptr = &heap[0];
91 d->distance = 0;
92 d->amount = sent;
93 d->score = 0;
94 i--;
95 } else {
96 heap[i] = n;
97 d->heapptr = &heap[i];
98 d->distance = UINT_MAX;
99 d->amount = AMOUNT_MSAT(-1ULL);
100 d->score = -1ULL;
101 }
102 }
103 assert(i == tal_count(heap));
104 return heap;
105}
106
107/* 365.25 * 24 * 60 / 10 */
108#define BLOCKS_PER_YEAR 52596

Callers 1

dijkstra_Function · 0.85

Calls 4

gossmap_num_nodesFunction · 0.85
gossmap_first_nodeFunction · 0.85
gossmap_next_nodeFunction · 0.85
get_dijkstraFunction · 0.85

Tested by

no test coverage detected