X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Frouting%2Frouter.rs;h=0a09ca81e3ffc6c13feca2c34391cac981128d62;hb=5824e226cad67e32d5e8be71ebbb6f91a3fc2116;hp=6fc3d4afa7b2c6a2eccf28c93368487a92897791;hpb=e1208bfd66908818604da97e924899d6843078da;p=rust-lightning diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 6fc3d4af..0a09ca81 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -61,7 +61,7 @@ impl>, 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 { let random_seed_bytes = { let mut locked_random_seed_bytes = self.random_seed_bytes.lock().unwrap(); @@ -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; /// 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 { self.find_route(payer, route_params, first_hops, inflight_htlcs) @@ -125,15 +125,15 @@ pub trait Router { /// [`find_route`]. /// /// [`Score`]: crate::routing::scoring::Score -pub struct ScorerAccountingForInFlightHtlcs { +pub struct ScorerAccountingForInFlightHtlcs<'a, S: Score> { 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 ScorerAccountingForInFlightHtlcs { +impl<'a, S: Score> ScorerAccountingForInFlightHtlcs<'a, S> { /// Initialize a new `ScorerAccountingForInFlightHtlcs`. - pub fn new(scorer: S, inflight_htlcs: InFlightHtlcs) -> Self { + pub fn new(scorer: S, inflight_htlcs: &'a InFlightHtlcs) -> Self { ScorerAccountingForInFlightHtlcs { scorer, inflight_htlcs @@ -142,11 +142,11 @@ impl ScorerAccountingForInFlightHtlcs { } #[cfg(c_bindings)] -impl Writeable for ScorerAccountingForInFlightHtlcs { +impl<'a, S: Score> Writeable for ScorerAccountingForInFlightHtlcs<'a, S> { fn write(&self, writer: &mut W) -> Result<(), io::Error> { self.scorer.write(writer) } } -impl Score for ScorerAccountingForInFlightHtlcs { +impl<'a, S: Score> Score for ScorerAccountingForInFlightHtlcs<'a, 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 @@ -2139,7 +2139,7 @@ mod tests { use crate::routing::scoring::{ChannelUsage, Score, ProbabilisticScorer, ProbabilisticScoringParameters}; use crate::routing::test_utils::{add_channel, add_or_update_node, build_graph, build_line_graph, id_to_feature_flags, get_nodes, update_channel}; use crate::chain::transaction::OutPoint; - use crate::chain::keysinterface::{EntropySource, KeysInterface}; + use crate::chain::keysinterface::EntropySource; use crate::ln::features::{ChannelFeatures, InitFeatures, NodeFeatures}; use crate::ln::msgs::{ErrorAction, LightningError, UnsignedChannelUpdate, MAX_VALUE_MSAT}; use crate::ln::channelmanager; @@ -5653,7 +5653,7 @@ mod benches { use bitcoin::hashes::Hash; use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; use crate::chain::transaction::OutPoint; - use crate::chain::keysinterface::{EntropySource, KeysManager,KeysInterface}; + use crate::chain::keysinterface::{EntropySource, KeysManager}; use crate::ln::channelmanager::{self, ChannelCounterparty, ChannelDetails}; use crate::ln::features::InvoiceFeatures; use crate::routing::gossip::NetworkGraph;