getroute: add a risk factor.

We need some way to reflect the tradeoff between the possible delay if
a payment gets stuck, and the fees charged by nodes.  This adds a risk
factor which reflects the probability that a node goes down, and the
cost associated with losing access to our funds for a given time.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-09-06 16:47:48 +09:30
parent e2bc70bfce
commit ca80fc0286
6 changed files with 60 additions and 12 deletions

View File

@@ -27,6 +27,8 @@ struct node {
struct {
/* Total to get to here from target. */
s64 total;
/* Total risk premium of this route. */
u64 risk;
/* Where that came from. */
struct node_connection *prev;
} bfg[ROUTING_MAX_HOPS+1];
@@ -56,7 +58,9 @@ void remove_connection(struct lightningd_state *dstate,
struct peer *find_route(struct lightningd_state *dstate,
const struct pubkey *to,
u64 msatoshi, s64 *fee,
u64 msatoshi,
double riskfactor,
s64 *fee,
struct node_connection ***route);
struct node_map *empty_node_map(struct lightningd_state *dstate);