Skip to content

Minor Bindings Tweaks #1218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lightning-invoice/src/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,12 @@ use std::time::{Duration, SystemTime};
/// See [module-level documentation] for details.
///
/// [module-level documentation]: crate::payment
pub struct InvoicePayer<P: Deref, R, S: Deref, L: Deref, E>
pub struct InvoicePayer<P: Deref, R, S: Deref, L: Deref, E: EventHandler>
where
P::Target: Payer,
R: for <'a> Router<<<S as Deref>::Target as LockableScore<'a>>::Locked>,
S::Target: for <'a> LockableScore<'a>,
L::Target: Logger,
E: EventHandler,
{
payer: P,
router: R,
Expand Down Expand Up @@ -221,13 +220,12 @@ pub enum PaymentError {
Sending(PaymentSendFailure),
}

impl<P: Deref, R, S: Deref, L: Deref, E> InvoicePayer<P, R, S, L, E>
impl<P: Deref, R, S: Deref, L: Deref, E: EventHandler> InvoicePayer<P, R, S, L, E>
where
P::Target: Payer,
R: for <'a> Router<<<S as Deref>::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.
///
Expand Down Expand Up @@ -455,13 +453,12 @@ fn has_expired(params: &RouteParameters) -> bool {
} else { false }
}

impl<P: Deref, R, S: Deref, L: Deref, E> EventHandler for InvoicePayer<P, R, S, L, E>
impl<P: Deref, R, S: Deref, L: Deref, E: EventHandler> EventHandler for InvoicePayer<P, R, S, L, E>
where
P::Target: Payer,
R: for <'a> Router<<<S as Deref>::Target as LockableScore<'a>>::Locked>,
S::Target: for <'a> LockableScore<'a>,
L::Target: Logger,
E: EventHandler,
{
fn handle_event(&self, event: &Event) {
match event {
Expand Down
2 changes: 2 additions & 0 deletions lightning/src/routing/network_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions lightning/src/routing/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ impl<'a, T: Score + 'a> LockableScore<'a> for MultiThreadedLockableScore<T> {
}
}

#[cfg(c_bindings)]
impl<T: Score> MultiThreadedLockableScore<T> {
/// 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> {
Expand Down