Move Scorer requirement away from Router trait
authorJurvis Tan <hello@jurvis.co>
Thu, 15 Sep 2022 21:58:08 +0000 (14:58 -0700)
committerjurvis <hello@jurvis.co>
Fri, 16 Sep 2022 15:38:56 +0000 (08:38 -0700)
commitc353c3ed7c40e689a3b9fb6730c6dabbd3c92cc5
tree2fce708741f650d792315d030c8f5566ffaec242
parentf99301dd8a7f056c0ed09ec827fddc00f325b3e5
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