askrene: make minflow() static, and remove unused linear_flow_cost.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -528,26 +528,6 @@ static double base_fee_penalty_estimate(struct amount_msat amount)
|
|||||||
return amount_msat_ratio(AMOUNT_MSAT(10000000), amount);
|
return amount_msat_ratio(AMOUNT_MSAT(10000000), amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct amount_msat linear_flow_cost(const struct flow *flow,
|
|
||||||
struct amount_msat total_amount,
|
|
||||||
double delay_feefactor)
|
|
||||||
{
|
|
||||||
struct amount_msat msat_cost;
|
|
||||||
s64 cost_ppm = 0;
|
|
||||||
double base_fee_penalty = base_fee_penalty_estimate(total_amount);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < tal_count(flow->path); i++) {
|
|
||||||
const struct half_chan *h = &flow->path[i]->half[flow->dirs[i]];
|
|
||||||
|
|
||||||
cost_ppm +=
|
|
||||||
linear_fee_cost(h->base_fee, h->proportional_fee, h->delay,
|
|
||||||
base_fee_penalty, delay_feefactor);
|
|
||||||
}
|
|
||||||
if (!amount_msat_fee(&msat_cost, flow->delivers, 0, cost_ppm))
|
|
||||||
abort();
|
|
||||||
return msat_cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void init_linear_network(const tal_t *ctx,
|
static void init_linear_network(const tal_t *ctx,
|
||||||
const struct pay_parameters *params,
|
const struct pay_parameters *params,
|
||||||
struct graph **graph, double **arc_prob_cost,
|
struct graph **graph, double **arc_prob_cost,
|
||||||
@@ -965,13 +945,13 @@ get_flow_singlepath(const tal_t *ctx, const struct pay_parameters *params,
|
|||||||
* Check that local channels have fee costs = 0 and bounds with certainty (min=max). */
|
* Check that local channels have fee costs = 0 and bounds with certainty (min=max). */
|
||||||
// TODO(eduardo): we should LOG_DBG the process of finding the MCF while
|
// TODO(eduardo): we should LOG_DBG the process of finding the MCF while
|
||||||
// adjusting the frugality factor.
|
// adjusting the frugality factor.
|
||||||
struct flow **minflow(const tal_t *ctx,
|
static struct flow **minflow(const tal_t *ctx,
|
||||||
const struct route_query *rq,
|
const struct route_query *rq,
|
||||||
const struct gossmap_node *source,
|
const struct gossmap_node *source,
|
||||||
const struct gossmap_node *target,
|
const struct gossmap_node *target,
|
||||||
struct amount_msat amount,
|
struct amount_msat amount,
|
||||||
u32 mu,
|
u32 mu,
|
||||||
double delay_feefactor)
|
double delay_feefactor)
|
||||||
{
|
{
|
||||||
struct flow **flow_paths;
|
struct flow **flow_paths;
|
||||||
/* We allocate everything off this, and free it at the end,
|
/* We allocate everything off this, and free it at the end,
|
||||||
@@ -1164,12 +1144,27 @@ static void init_linear_network_single_path(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Similar to minflow but computes routes that have a single path. */
|
/**
|
||||||
struct flow **single_path_flow(const tal_t *ctx, const struct route_query *rq,
|
* API for min cost single path.
|
||||||
const struct gossmap_node *source,
|
* @ctx: context to allocate returned flows from
|
||||||
const struct gossmap_node *target,
|
* @rq: the route_query we're processing (for logging)
|
||||||
struct amount_msat amount, u32 mu,
|
* @source: the source to start from
|
||||||
double delay_feefactor)
|
* @target: the target to pay
|
||||||
|
* @amount: the amount we want to reach @target
|
||||||
|
* @mu: 0 = corresponds to only probabilities, 100 corresponds to only fee.
|
||||||
|
* @delay_feefactor: convert 1 block delay into msat.
|
||||||
|
*
|
||||||
|
* @delay_feefactor converts 1 block delay into msat, as if it were an additional
|
||||||
|
* fee. So if a CLTV delay on a node is 5 blocks, that's treated as if it
|
||||||
|
* were a fee of 5 * @delay_feefactor.
|
||||||
|
*
|
||||||
|
* Returns an array with one flow which deliver amount to target, or NULL.
|
||||||
|
*/
|
||||||
|
static struct flow **single_path_flow(const tal_t *ctx, const struct route_query *rq,
|
||||||
|
const struct gossmap_node *source,
|
||||||
|
const struct gossmap_node *target,
|
||||||
|
struct amount_msat amount, u32 mu,
|
||||||
|
double delay_feefactor)
|
||||||
{
|
{
|
||||||
struct flow **flow_paths;
|
struct flow **flow_paths;
|
||||||
/* We allocate everything off this, and free it at the end,
|
/* We allocate everything off this, and free it at the end,
|
||||||
|
|||||||
@@ -8,59 +8,6 @@
|
|||||||
|
|
||||||
struct route_query;
|
struct route_query;
|
||||||
|
|
||||||
/**
|
|
||||||
* optimal_payment_flow - API for min cost flow function(s).
|
|
||||||
* @ctx: context to allocate returned flows from
|
|
||||||
* @rq: the route_query we're processing (for logging)
|
|
||||||
* @source: the source to start from
|
|
||||||
* @target: the target to pay
|
|
||||||
* @amount: the amount we want to reach @target
|
|
||||||
* @mu: 0 = corresponds to only probabilities, 100 corresponds to only fee.
|
|
||||||
* @delay_feefactor: convert 1 block delay into msat.
|
|
||||||
* @single_part: don't do MCF at all, just create a single flow.
|
|
||||||
*
|
|
||||||
* @delay_feefactor converts 1 block delay into msat, as if it were an additional
|
|
||||||
* fee. So if a CLTV delay on a node is 5 blocks, that's treated as if it
|
|
||||||
* were a fee of 5 * @delay_feefactor.
|
|
||||||
*
|
|
||||||
* Return a series of subflows which deliver amount to target, or NULL.
|
|
||||||
*/
|
|
||||||
struct flow **minflow(const tal_t *ctx,
|
|
||||||
const struct route_query *rq,
|
|
||||||
const struct gossmap_node *source,
|
|
||||||
const struct gossmap_node *target,
|
|
||||||
struct amount_msat amount,
|
|
||||||
u32 mu,
|
|
||||||
double delay_feefactor);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API for min cost single path.
|
|
||||||
* @ctx: context to allocate returned flows from
|
|
||||||
* @rq: the route_query we're processing (for logging)
|
|
||||||
* @source: the source to start from
|
|
||||||
* @target: the target to pay
|
|
||||||
* @amount: the amount we want to reach @target
|
|
||||||
* @mu: 0 = corresponds to only probabilities, 100 corresponds to only fee.
|
|
||||||
* @delay_feefactor: convert 1 block delay into msat.
|
|
||||||
*
|
|
||||||
* @delay_feefactor converts 1 block delay into msat, as if it were an additional
|
|
||||||
* fee. So if a CLTV delay on a node is 5 blocks, that's treated as if it
|
|
||||||
* were a fee of 5 * @delay_feefactor.
|
|
||||||
*
|
|
||||||
* Returns an array with one flow which deliver amount to target, or NULL.
|
|
||||||
*/
|
|
||||||
struct flow **single_path_flow(const tal_t *ctx, const struct route_query *rq,
|
|
||||||
const struct gossmap_node *source,
|
|
||||||
const struct gossmap_node *target,
|
|
||||||
struct amount_msat amount, u32 mu,
|
|
||||||
double delay_feefactor);
|
|
||||||
|
|
||||||
/* To sanity check: this is the approximation mcf uses for the cost
|
|
||||||
* of each channel. */
|
|
||||||
struct amount_msat linear_flow_cost(const struct flow *flow,
|
|
||||||
struct amount_msat total_amount,
|
|
||||||
double delay_feefactor);
|
|
||||||
|
|
||||||
/* A wrapper to the min. cost flow solver that actually takes into consideration
|
/* A wrapper to the min. cost flow solver that actually takes into consideration
|
||||||
* the extra msats per channel needed to pay for fees. */
|
* the extra msats per channel needed to pay for fees. */
|
||||||
const char *default_routes(const tal_t *ctx, struct route_query *rq,
|
const char *default_routes(const tal_t *ctx, struct route_query *rq,
|
||||||
|
|||||||
Reference in New Issue
Block a user