mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
Even after the previous fix, we still occasionally increase fees when my increases. This is due to the difference between MCF's linear fees, and actual fees, and is unavoidable, but add a check if it somehow happens. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
40 lines
1.4 KiB
C
40 lines
1.4 KiB
C
#ifndef LIGHTNING_PLUGINS_ASKRENE_MCF_H
|
|
#define LIGHTNING_PLUGINS_ASKRENE_MCF_H
|
|
/* Eduardo Quintela's (lagrang3@protonmail.com) Min Cost Flow implementation
|
|
* from renepay, as modified to fit askrene */
|
|
#include "config.h"
|
|
#include <common/amount.h>
|
|
#include <common/gossmap.h>
|
|
|
|
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 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);
|
|
|
|
/* 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);
|
|
|
|
#endif /* LIGHTNING_PLUGINS_ASKRENE_MCF_H */
|