Effective channel capacity for router and scoring
authorJeffrey Czyz <jkczyz@gmail.com>
Wed, 29 Dec 2021 15:56:54 +0000 (09:56 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Thu, 3 Feb 2022 01:46:58 +0000 (19:46 -0600)
commit1aaf5fc5d01837b6c31a3f03cca5f7f811759207
tree8cfa7045129ca6d1e61db216f1b5d14469541d7e
parent457e48e1025aced95ccca65d9ca78ec6b0a4ed61
Effective channel capacity for router and scoring

A channel's capacity may be inferred or learned and is used to make
routing decisions, including as a parameter to channel scoring. Define
an EffectiveCapacity for this purpose. Score::channel_penalty_msat takes
the effective capacity (less in-flight HTLCs for the same payment), and
never None. Thus, for hops given in an invoice, the effective capacity
is now considered (near) infinite if over a private channel or based on
learned information if over a public channel.

If a Score implementations needs the effective capacity when updating a
channel's score, i.e. in payment_path_failed or payment_path_successful,
it can access the channel's EffectiveCapacity via the NetworkGraph by
first looking up the channel and then specifying which direction is
desired using ChannelInfo::as_directed.
lightning-invoice/src/payment.rs
lightning/src/routing/network_graph.rs
lightning/src/routing/router.rs
lightning/src/routing/scoring.rs