Merge pull request #1823 from mariocynicys/expose-tlv-macros2
[rust-lightning] / lightning / src / routing / router.rs
index e60449e15639561c73c75b239d6abbe3e04b4305..3f14b0c6a1128a366d8b80c9b59c216febe0b816 100644 (file)
@@ -61,7 +61,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, S: Deref> Router for DefaultR
 {
        fn find_route(
                &self, payer: &PublicKey, params: &RouteParameters, first_hops: Option<&[&ChannelDetails]>,
-               inflight_htlcs: InFlightHtlcs
+               inflight_htlcs: &InFlightHtlcs
        ) -> Result<Route, LightningError> {
                let random_seed_bytes = {
                        let mut locked_random_seed_bytes = self.random_seed_bytes.lock().unwrap();
@@ -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
                )
        }
@@ -98,13 +98,13 @@ pub trait Router {
        /// Finds a [`Route`] between `payer` and `payee` for a payment with the given values.
        fn find_route(
                &self, payer: &PublicKey, route_params: &RouteParameters,
-               first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: InFlightHtlcs
+               first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: &InFlightHtlcs
        ) -> Result<Route, LightningError>;
        /// Finds a [`Route`] between `payer` and `payee` for a payment with the given values. Includes
        /// `PaymentHash` and `PaymentId` to be able to correlate the request with a specific payment.
        fn find_route_with_id(
                &self, payer: &PublicKey, route_params: &RouteParameters,
-               first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: InFlightHtlcs,
+               first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: &InFlightHtlcs,
                _payment_hash: PaymentHash, _payment_id: PaymentId
        ) -> Result<Route, LightningError> {
                self.find_route(payer, route_params, first_hops, inflight_htlcs)
@@ -126,14 +126,14 @@ pub trait Router {
 ///
 /// [`Score`]: crate::routing::scoring::Score
 pub struct ScorerAccountingForInFlightHtlcs<'a, S: Score> {
-       scorer: &'a mut S,
+       scorer: S,
        // Maps a channel's short channel id and its direction to the liquidity used up.
-       inflight_htlcs: InFlightHtlcs,
+       inflight_htlcs: &'a InFlightHtlcs,
 }
 
 impl<'a, S: Score> ScorerAccountingForInFlightHtlcs<'a, S> {
        /// Initialize a new `ScorerAccountingForInFlightHtlcs`.
-       pub fn new(scorer: &'a mut S, inflight_htlcs: InFlightHtlcs) -> Self {
+       pub fn new(scorer: S, inflight_htlcs: &'a InFlightHtlcs) -> Self {
                ScorerAccountingForInFlightHtlcs {
                        scorer,
                        inflight_htlcs
@@ -142,7 +142,7 @@ impl<'a, S: Score> ScorerAccountingForInFlightHtlcs<'a, S> {
 }
 
 #[cfg(c_bindings)]
-impl<'a, S:Score> Writeable for ScorerAccountingForInFlightHtlcs<'a, S> {
+impl<'a, S: Score> Writeable for ScorerAccountingForInFlightHtlcs<'a, S> {
        fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> { self.scorer.write(writer) }
 }