Skip to content

Trivial Bindings Updates #1934

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
4 changes: 2 additions & 2 deletions lightning-invoice/src/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1674,8 +1674,8 @@ mod tests {
) -> Result<Route, LightningError> {
// Simulate calling the Scorer just as you would in find_route
let route = Self::route_for_value(route_params.final_value_msat);
let mut locked_scorer = self.scorer.lock();
let scorer = ScorerAccountingForInFlightHtlcs::new(locked_scorer.deref_mut(), inflight_htlcs);
let locked_scorer = self.scorer.lock();
let scorer = ScorerAccountingForInFlightHtlcs::new(locked_scorer, inflight_htlcs);
for path in route.paths {
let mut aggregate_msat = 0u64;
for (idx, hop) in path.iter().rev().enumerate() {
Expand Down
3 changes: 3 additions & 0 deletions lightning/src/onion_message/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,16 @@ pub enum OnionMessageContents<T: CustomOnionMessageContents> {

impl<T: CustomOnionMessageContents> OnionMessageContents<T> {
/// Returns the type that was used to decode the message payload.
///
/// (C-not exported) as methods on non-cloneable enums are not currently exportable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a release note somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally haven't release-noted this kinda thing. The nice thing about the comments is they appear in the documentation, but sadly when we do the bindings update after the release they won't show up until the next release :(. Once we get to 0.1 I want to redo our release process to do a rcX release, then update the bindings, then once that's done do the actual release.

pub fn tlv_type(&self) -> u64 {
match self {
&OnionMessageContents::Custom(ref msg) => msg.tlv_type(),
}
}
}

/// (C-not exported) as methods on non-cloneable enums are not currently exportable
impl<T: CustomOnionMessageContents> Writeable for OnionMessageContents<T> {
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
match self {
Expand Down
14 changes: 7 additions & 7 deletions lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, S: Deref> Router for DefaultR

find_route(
payer, params, &self.network_graph, first_hops, &*self.logger,
&ScorerAccountingForInFlightHtlcs::new(&mut self.scorer.lock(), inflight_htlcs),
&ScorerAccountingForInFlightHtlcs::new(self.scorer.lock(), inflight_htlcs),
&random_seed_bytes
)
}
Expand Down Expand Up @@ -125,15 +125,15 @@ pub trait Router {
/// [`find_route`].
///
/// [`Score`]: crate::routing::scoring::Score
pub struct ScorerAccountingForInFlightHtlcs<'a, S: Score> {
scorer: &'a mut S,
pub struct ScorerAccountingForInFlightHtlcs<S: Score> {
scorer: S,
// Maps a channel's short channel id and its direction to the liquidity used up.
inflight_htlcs: InFlightHtlcs,
}

impl<'a, S: Score> ScorerAccountingForInFlightHtlcs<'a, S> {
impl<S: Score> ScorerAccountingForInFlightHtlcs<S> {
/// Initialize a new `ScorerAccountingForInFlightHtlcs`.
pub fn new(scorer: &'a mut S, inflight_htlcs: InFlightHtlcs) -> Self {
pub fn new(scorer: S, inflight_htlcs: InFlightHtlcs) -> Self {
ScorerAccountingForInFlightHtlcs {
scorer,
inflight_htlcs
Expand All @@ -142,11 +142,11 @@ impl<'a, S: Score> ScorerAccountingForInFlightHtlcs<'a, S> {
}

#[cfg(c_bindings)]
impl<'a, S:Score> Writeable for ScorerAccountingForInFlightHtlcs<'a, S> {
impl<S: Score> Writeable for ScorerAccountingForInFlightHtlcs<S> {
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> { self.scorer.write(writer) }
}

impl<'a, S: Score> Score for ScorerAccountingForInFlightHtlcs<'a, S> {
impl<S: Score> Score for ScorerAccountingForInFlightHtlcs<S> {
fn channel_penalty_msat(&self, short_channel_id: u64, source: &NodeId, target: &NodeId, usage: ChannelUsage) -> u64 {
if let Some(used_liquidity) = self.inflight_htlcs.used_liquidity_msat(
source, target, short_channel_id
Expand Down