Seal `scoring::Time` and only use `Instant` or `Eternity` publicly 2021-11-c-bindings-tweaks
authorMatt Corallo <git@bluematt.me>
Mon, 22 Nov 2021 18:00:08 +0000 (18:00 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 24 Nov 2021 19:08:12 +0000 (19:08 +0000)
commit3539f270c47ec8b525bac65fce2b85c94eb55be9
treea83e755ee9a115f5050b85fbceaea2bde1a4d851
parenta173ded03f84193f8da14301e81fdec419c5e441
Seal `scoring::Time` and only use `Instant` or `Eternity` publicly

`scoring::Time` exists in part to make testing the passage of time
in `Scorer` practical. To allow no-std users to provide a time
source it was exposed as a trait as well. However, it seems
somewhat unlikely that a no-std user is going to have a use for
providing their own time source (otherwise they wouldn't be a
no-std user), and likely they won't have a graph in memory either.

`scoring::Time` as currently written is also exceptionally hard to
write C bindings for - the C bindings trait mappings relies on the
ability to construct trait implementations at runtime with function
pointers (i.e. `dyn Trait`s). `scoring::Time`, on the other hand,
is a supertrait of `core::ops::Sub` which requires a `sub` method
which takes a type parameter and returns a type parameter. Both of
which aren't practical in bindings, especially given the
`Sub::Output` associated type is not bound by any trait bounds at
all (implying we cannot simply map the `sub` function to return an
opaque trait object).

Thus, for simplicity, we here simply seal `scoring::Time` and make
it effectively-private, ensuring the bindings don't need to bother
with it.
lightning/src/routing/scoring.rs
lightning/src/util/test_utils.rs