TODO(eduardo): choose some default values for the minflow parameters eduardo: I think it should be clear that this module deals with linear * flows, ie. base fees are not considered. Hence a flow along a path is * described with a sequence of directed channels and one amount. * In the `pay_flow` module there are dedicated routes to compute the actual * amount to be forward on each hop. * * T
| 1613 | // TODO(eduardo): we should LOG_DBG the process of finding the MCF while |
| 1614 | // adjusting the frugality factor. |
| 1615 | struct flow **minflow(const tal_t *ctx, struct gossmap *gossmap, |
| 1616 | const struct gossmap_node *source, |
| 1617 | const struct gossmap_node *target, |
| 1618 | struct chan_extra_map *chan_extra_map, |
| 1619 | const bitmap *disabled, struct amount_msat amount, |
| 1620 | struct amount_msat max_fee, double min_probability, |
| 1621 | double base_probability, |
| 1622 | double delay_feefactor, double base_fee_penalty, |
| 1623 | u32 prob_cost_factor, char **fail) |
| 1624 | { |
| 1625 | tal_t *this_ctx = tal(ctx,tal_t); |
| 1626 | char *errmsg; |
| 1627 | struct flow **best_flow_paths = NULL; |
| 1628 | |
| 1629 | struct pay_parameters *params = tal(this_ctx,struct pay_parameters); |
| 1630 | struct dijkstra *dijkstra; |
| 1631 | |
| 1632 | params->gossmap = gossmap; |
| 1633 | params->source = source; |
| 1634 | params->target = target; |
| 1635 | params->chan_extra_map = chan_extra_map; |
| 1636 | |
| 1637 | params->disabled = disabled; |
| 1638 | |
| 1639 | if (!check_disabled(disabled, gossmap, chan_extra_map)) { |
| 1640 | if (fail) |
| 1641 | *fail = tal_fmt(ctx, "Invalid disabled bitmap."); |
| 1642 | goto function_fail; |
| 1643 | } |
| 1644 | |
| 1645 | params->amount = amount; |
| 1646 | |
| 1647 | // template the channel partition into linear arcs |
| 1648 | params->cap_fraction[0]=0; |
| 1649 | params->cost_fraction[0]=0; |
| 1650 | for(size_t i =1;i<CHANNEL_PARTS;++i) |
| 1651 | { |
| 1652 | params->cap_fraction[i]=CHANNEL_PIVOTS[i]-CHANNEL_PIVOTS[i-1]; |
| 1653 | params->cost_fraction[i]= |
| 1654 | log((1-CHANNEL_PIVOTS[i-1])/(1-CHANNEL_PIVOTS[i])) |
| 1655 | /params->cap_fraction[i]; |
| 1656 | |
| 1657 | // printf("channel part: %ld, fraction: %lf, cost_fraction: %lf\n", |
| 1658 | // i,params->cap_fraction[i],params->cost_fraction[i]); |
| 1659 | } |
| 1660 | |
| 1661 | params->max_fee = max_fee; |
| 1662 | params->min_probability = min_probability; |
| 1663 | params->delay_feefactor = delay_feefactor; |
| 1664 | params->base_fee_penalty = base_fee_penalty; |
| 1665 | params->prob_cost_factor = prob_cost_factor; |
| 1666 | params->base_probability = base_probability; |
| 1667 | |
| 1668 | // build the uncertainty network with linearization and residual arcs |
| 1669 | struct linear_network *linear_network= init_linear_network(this_ctx, params, &errmsg); |
| 1670 | if (!linear_network) { |
| 1671 | if(fail) |
| 1672 | *fail = tal_fmt(ctx, "init_linear_network failed: %s", |