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

Function get_flow_singlepath

plugins/askrene/child/mcf.c:897–934  ·  view source on GitHub ↗

Given a single path build a flow set. */

Source from the content-addressed store, hash-verified

895
896/* Given a single path build a flow set. */
897static struct flow **
898get_flow_singlepath(const tal_t *ctx, const struct pay_parameters *params,
899 const struct graph *graph, const struct gossmap *gossmap,
900 const struct node source, const struct node destination,
901 const u64 pay_amount, const struct arc *prev)
902{
903 struct flow **flows, *f;
904 flows = tal_arr(ctx, struct flow *, 1);
905 f = flows[0] = tal(flows, struct flow);
906
907 size_t length = 0;
908
909 for (u32 cur_idx = destination.idx; cur_idx != source.idx;) {
910 assert(cur_idx != INVALID_INDEX);
911 length++;
912 struct arc arc = prev[cur_idx];
913 struct node next = arc_tail(graph, arc);
914 cur_idx = next.idx;
915 }
916 f->path = tal_arr(f, const struct gossmap_chan *, length);
917 f->dirs = tal_arr(f, int, length);
918
919 for (u32 cur_idx = destination.idx; cur_idx != source.idx;) {
920 int chandir;
921 u32 chanidx;
922 struct arc arc = prev[cur_idx];
923 arc_to_parts(arc, &chanidx, &chandir, NULL, NULL);
924
925 length--;
926 f->path[length] = gossmap_chan_byidx(gossmap, chanidx);
927 f->dirs[length] = chandir;
928
929 struct node next = arc_tail(graph, arc);
930 cur_idx = next.idx;
931 }
932 f->delivers = params->amount;
933 return flows;
934}
935
936// TODO(eduardo): choose some default values for the minflow parameters
937/* 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