Move Scorer requirement away from Router trait
authorJurvis Tan <hello@jurvis.co>
Thu, 15 Sep 2022 21:58:08 +0000 (14:58 -0700)
committerMatt Corallo <git@bluematt.me>
Mon, 19 Sep 2022 15:22:07 +0000 (15:22 +0000)
commit23f5605780122f7624fb9138c469422f8b598e87
tree7c32144e6ef729a68ded0a1f7b40f695ac846d3c
parent4ae65e8f4f07fb5e35e57350cdc1bc7dbe5f7e4c
Move Scorer requirement away from Router trait

We do this to enable users to create routers that do not need a scorer.
This can be useful if they are running a node the delegates pathfinding.

* Move `Score` type parameterization from `InvoicePayer` and `Router` to
`DefaultRouter`
* Adds a new field, `scorer`, to `DefaultRouter`
* Move `AccountsForInFlightHtlcs` to `DefaultRouter`, which we
will use to wrap the new `scorer` field, so scoring only happens in
`DefaultRouter` explicitly.
* Add scoring related functions to `Router` trait that we used to call
directly from `InvoicePayer`.
* Instead of parameterizing `scorer` in `find_route`, we replace it with
inflight_map so `InvoicePayer` can pass on information about inflight
HTLCs to the router.
* Introduced a new tuple struct, InFlightHtlcs, that wraps functionality
for querying used liquidity.
lightning-background-processor/src/lib.rs
lightning-invoice/Cargo.toml
lightning-invoice/src/payment.rs
lightning-invoice/src/utils.rs