From ae4f6198db4bf1dd5ab708c625276143d53239ba Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 18 Dec 2021 03:38:15 +0000 Subject: [PATCH 1/3] Add a constructor to MultiThreadedLockableScore ...as otherwise the struct is rather useless. --- lightning/src/routing/scoring.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index 2b2839d69db..20a8afcabcf 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -168,6 +168,14 @@ impl<'a, T: Score + 'a> LockableScore<'a> for MultiThreadedLockableScore { } } +#[cfg(c_bindings)] +impl MultiThreadedLockableScore { + /// Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. + pub fn new(score: T) -> Self { + MultiThreadedLockableScore { score: Mutex::new(score) } + } +} + #[cfg(c_bindings)] /// (C-not exported) impl<'a, T: Writeable> Writeable for RefMut<'a, T> { From d26469a77a96bcf3717d321b6befce64661e8ed4 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 18 Dec 2021 03:43:34 +0000 Subject: [PATCH 2/3] Add a C-not exported tag to `NetGraphMsgHandler.network_graph` --- lightning/src/routing/network_graph.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lightning/src/routing/network_graph.rs b/lightning/src/routing/network_graph.rs index 8f3c44b80a7..ae597d30364 100644 --- a/lightning/src/routing/network_graph.rs +++ b/lightning/src/routing/network_graph.rs @@ -251,6 +251,8 @@ where C::Target: chain::Access, L::Target: Logger /// Gets a reference to the underlying [`NetworkGraph`] which was provided in /// [`NetGraphMsgHandler::new`]. + /// + /// (C-not exported) as bindings don't support a reference-to-a-reference yet pub fn network_graph(&self) -> &G { &self.network_graph } From 7d1e1873f34b1de87ec9cfbe13c9111f892b5c8d Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 18 Dec 2021 19:52:11 +0000 Subject: [PATCH 3/3] Swap around generic argument ordering in InvoicePayer for bindings The bindings generation really should support generic bounds other than Deref::Target in where clauses, but currently does not. To avoid needing to add support during the current release process, we simply swap around the arguments to move them to the first <> instead of the where. --- lightning-invoice/src/payment.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lightning-invoice/src/payment.rs b/lightning-invoice/src/payment.rs index d08f38facd4..4e249a85c3f 100644 --- a/lightning-invoice/src/payment.rs +++ b/lightning-invoice/src/payment.rs @@ -150,13 +150,12 @@ use std::time::{Duration, SystemTime}; /// See [module-level documentation] for details. /// /// [module-level documentation]: crate::payment -pub struct InvoicePayer +pub struct InvoicePayer where P::Target: Payer, R: for <'a> Router<<::Target as LockableScore<'a>>::Locked>, S::Target: for <'a> LockableScore<'a>, L::Target: Logger, - E: EventHandler, { payer: P, router: R, @@ -221,13 +220,12 @@ pub enum PaymentError { Sending(PaymentSendFailure), } -impl InvoicePayer +impl InvoicePayer where P::Target: Payer, R: for <'a> Router<<::Target as LockableScore<'a>>::Locked>, S::Target: for <'a> LockableScore<'a>, L::Target: Logger, - E: EventHandler, { /// Creates an invoice payer that retries failed payment paths. /// @@ -455,13 +453,12 @@ fn has_expired(params: &RouteParameters) -> bool { } else { false } } -impl EventHandler for InvoicePayer +impl EventHandler for InvoicePayer where P::Target: Payer, R: for <'a> Router<<::Target as LockableScore<'a>>::Locked>, S::Target: for <'a> LockableScore<'a>, L::Target: Logger, - E: EventHandler, { fn handle_event(&self, event: &Event) { match event {