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

Function main

common/test/run-route-infloop.c:107–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107int main(int argc, char *argv[])
108{
109 const double riskfactor = 10;
110 const u32 final_delay = 159;
111 struct node_id my_id;
112 const struct gossmap_node **nodes, *me;
113 u64 amt;
114
115 common_setup(argv[0]);
116
117 /* This used to crash! */
118 if (!argv[1])
119 amt = 8388607;
120 else
121 amt = atol(argv[1]);
122 gossmap = gossmap_load(tmpctx, "tests/data/routing_gossip_store", NULL, NULL);
123
124 nodes = tal_arr(tmpctx, const struct gossmap_node *, 0);
125 for (struct gossmap_node *n = gossmap_first_node(gossmap);
126 n;
127 n = gossmap_next_node(gossmap, n)) {
128 tal_arr_expand(&nodes, n);
129 }
130
131 assert(node_id_from_hexstr("03942f5fe67645fdce4584e7f159c1f0a396b05fbc15f0fb7d6e83c553037b1c73",
132 strlen("03942f5fe67645fdce4584e7f159c1f0a396b05fbc15f0fb7d6e83c553037b1c73"),
133 &my_id));
134 me = gossmap_find_node(gossmap, &my_id);
135 assert(me);
136
137 /* We overlay our own channels as zero fee & delay, since we don't pay fees */
138 struct gossmap_localmods *localmods = gossmap_localmods_new(gossmap);
139 for (size_t i = 0; i < me->num_chans; i++) {
140 struct short_channel_id_dir scidd;
141 const struct amount_msat base_fee = AMOUNT_MSAT(0);
142 const u32 proportional_fee = 0;
143 struct gossmap_chan *c = gossmap_nth_chan(gossmap, me, i, &scidd.dir);
144
145 if (!c->half[scidd.dir].enabled)
146 continue;
147 scidd.scid = gossmap_chan_scid(gossmap, c);
148 assert(gossmap_local_updatechan(localmods, &scidd,
149 NULL, NULL, NULL,
150 &base_fee, &proportional_fee,
151 NULL));
152 }
153 gossmap_apply_localmods(gossmap, localmods);
154
155 printf("Destination node, success, probability, hops, fees, cltv, scid...\n");
156 for (size_t i = 0; i < tal_count(nodes); i++) {
157 const struct dijkstra *dij;
158 struct route_hop *r;
159 struct node_id them;
160
161 if (nodes[i] == me)
162 continue;
163
164 dij = dijkstra(tmpctx, gossmap, nodes[i], amount_msat(amt), riskfactor,

Callers

nothing calls this directly

Calls 15

common_setupFunction · 0.85
gossmap_first_nodeFunction · 0.85
gossmap_next_nodeFunction · 0.85
gossmap_find_nodeFunction · 0.85
gossmap_localmods_newFunction · 0.85
gossmap_nth_chanFunction · 0.85
gossmap_chan_scidFunction · 0.85
gossmap_local_updatechanFunction · 0.85
gossmap_apply_localmodsFunction · 0.85
route_from_dijkstraFunction · 0.85
gossmap_node_get_idFunction · 0.85
fmt_node_idFunction · 0.85

Tested by

no test coverage detected