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