Merge pull request #1934 from TheBlueMatt/2022-12-113-bindings-upstream
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Tue, 3 Jan 2023 17:06:37 +0000 (17:06 +0000)
committerGitHub <noreply@github.com>
Tue, 3 Jan 2023 17:06:37 +0000 (17:06 +0000)
Trivial Bindings Updates

lightning-invoice/src/payment.rs
lightning/src/onion_message/packet.rs
lightning/src/routing/router.rs

index 4fddedc0c0749e908889fcdc82db028c877c4612..03dc9361f7e4fecf827b9878c569bb412a8c163f 100644 (file)
@@ -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() {
index 3222c08a39263c7d1ab78113f2987e505257059c..5ff226387107ae23f839dc376d1db15d73c8a345 100644 (file)
@@ -118,6 +118,8 @@ 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
        pub fn tlv_type(&self) -> u64 {
                match self {
                        &OnionMessageContents::Custom(ref msg) => msg.tlv_type(),
@@ -125,6 +127,7 @@ impl<T: CustomOnionMessageContents> OnionMessageContents<T> {
        }
 }
 
+/// (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 {
index e60449e15639561c73c75b239d6abbe3e04b4305..6fc3d4afa7b2c6a2eccf28c93368487a92897791 100644 (file)
@@ -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
                )
        }
@@ -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
@@ -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