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

Function get_flow_singlepath

plugins/askrene/child/mcf.c:971–1008  ·  view source on GitHub ↗

Given a single path build a flow set. */

Source from the content-addressed store, hash-verified

969
970/* Given a single path build a flow set. */
971static struct flow **
972get_flow_singlepath(const tal_t *ctx, const struct pay_parameters *params,
973 const struct graph *graph, const struct gossmap *gossmap,
974 const struct node source, const struct node destination,
975 const u64 pay_amount, const struct arc *prev)
976{
977 struct flow **flows, *f;
978 flows = tal_arr(ctx, struct flow *, 1);
979 f = flows[0] = tal(flows, struct flow);
980
981 size_t length = 0;
982
983 for (u32 cur_idx = destination.idx; cur_idx != source.idx;) {
984 assert(cur_idx != INVALID_INDEX);
985 length++;
986 struct arc arc = prev[cur_idx];
987 struct node next = arc_tail(graph, arc);
988 cur_idx = next.idx;
989 }
990 f->path = tal_arr(f, const struct gossmap_chan *, length);
991 f->dirs = tal_arr(f, int, length);
992
993 for (u32 cur_idx = destination.idx; cur_idx != source.idx;) {
994 int chandir;
995 u32 chanidx;
996 struct arc arc = prev[cur_idx];
997 arc_to_parts(arc, &chanidx, &chandir, NULL, NULL);
998
999 length--;
1000 f->path[length] = gossmap_chan_byidx(gossmap, chanidx);
1001 f->dirs[length] = chandir;
1002
1003 struct node next = arc_tail(graph, arc);
1004 cur_idx = next.idx;
1005 }
1006 f->delivers = params->amount;
1007 return flows;
1008}
1009
1010// TODO(eduardo): choose some default values for the minflow parameters
1011/* eduardo: I think it should be clear that this module deals with linear

Callers 1

single_path_flowFunction · 0.85

Calls 3

gossmap_chan_byidxFunction · 0.85
arc_tailFunction · 0.70
arc_to_partsFunction · 0.70

Tested by

no test coverage detected