};
find_route(
payer, params, &self.network_graph, first_hops, &*self.logger,
- &ScorerAccountingForInFlightHtlcs::new(self.scorer.lock().deref_mut(), &inflight_htlcs),
+ &ScorerAccountingForInFlightHtlcs::new(self.scorer.lock(), &inflight_htlcs),
&self.score_params,
&random_seed_bytes
)
/// [`find_route`].
///
/// [`Score`]: crate::routing::scoring::Score
-pub struct ScorerAccountingForInFlightHtlcs<'a, S: Score<ScoreParams = SP>, SP: Sized> {
- scorer: &'a mut S,
+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: &'a InFlightHtlcs,
}
-impl<'a, S: Score<ScoreParams = SP>, SP: Sized> ScorerAccountingForInFlightHtlcs<'a, S, SP> {
+impl<'a, S: Score> ScorerAccountingForInFlightHtlcs<'a, S> {
/// Initialize a new `ScorerAccountingForInFlightHtlcs`.
- pub fn new(scorer: &'a mut S, inflight_htlcs: &'a InFlightHtlcs) -> Self {
+ pub fn new(scorer: S, inflight_htlcs: &'a InFlightHtlcs) -> Self {
ScorerAccountingForInFlightHtlcs {
scorer,
inflight_htlcs
}
#[cfg(c_bindings)]
-impl<'a, S: Score<ScoreParams = SP>, SP: Sized> Writeable for ScorerAccountingForInFlightHtlcs<'a, S, SP> {
+impl<'a, S: Score> Writeable for ScorerAccountingForInFlightHtlcs<'a, S> {
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> { self.scorer.write(writer) }
}
-impl<'a, S: Score<ScoreParams = SP>, SP: Sized> Score for ScorerAccountingForInFlightHtlcs<'a, S, SP> {
+impl<'a, S: Score> Score for ScorerAccountingForInFlightHtlcs<'a, S> {
#[cfg(not(c_bindings))]
type ScoreParams = S::ScoreParams;
fn channel_penalty_msat(&self, short_channel_id: u64, source: &NodeId, target: &NodeId, usage: ChannelUsage, score_params: &crate::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 {
///
/// [`find_route`]: crate::routing::router::find_route
pub trait LockableScore<'a> {
- /// The [`Score`] type.
- type Score: 'a + Score;
-
/// The locked [`Score`] type.
- type Locked: DerefMut<Target = Self::Score> + Sized;
+ type Locked: 'a + Score;
/// Returns the locked scorer.
fn lock(&'a self) -> Self::Locked;
impl<'a, T> WriteableScore<'a> for T where T: LockableScore<'a> + Writeable {}
#[cfg(not(c_bindings))]
impl<'a, T: 'a + Score> LockableScore<'a> for Mutex<T> {
- type Score = T;
type Locked = MutexGuard<'a, T>;
fn lock(&'a self) -> Self::Locked {
#[cfg(not(c_bindings))]
impl<'a, T: 'a + Score> LockableScore<'a> for RefCell<T> {
- type Score = T;
type Locked = RefMut<'a, T>;
fn lock(&'a self) -> Self::Locked {
#[cfg(c_bindings)]
impl<'a, T: 'a + Score> LockableScore<'a> for MultiThreadedLockableScore<T> {
- type Score = T;
type Locked = MultiThreadedScoreLock<'a, T>;
fn lock(&'a self) -> Self::Locked {
}
#[cfg(c_bindings)]
-impl<'a, T: 'a + Score> DerefMut for MultiThreadedScoreLock<'a, T> {
- fn deref_mut(&mut self) -> &mut Self::Target {
- self.0.deref_mut()
- }
-}
+impl<'a, T: 'a + Score> Score for MultiThreadedScoreLock<'a, T> {
+ fn channel_penalty_msat(
+ &self, short_channel_id: u64, source: &NodeId, target: &NodeId, usage: ChannelUsage, score_params: &ProbabilisticScoringFeeParameters
+ ) -> u64 {
+ self.0.channel_penalty_msat(short_channel_id, source, target, usage, score_params)
+ }
-#[cfg(c_bindings)]
-impl<'a, T: 'a + Score> Deref for MultiThreadedScoreLock<'a, T> {
- type Target = T;
+ fn payment_path_failed(&mut self, path: &Path, short_channel_id: u64) {
+ self.0.payment_path_failed(path, short_channel_id)
+ }
- fn deref(&self) -> &Self::Target {
- self.0.deref()
- }
-}
+ fn payment_path_successful(&mut self, path: &Path) {
+ self.0.payment_path_successful(path)
+ }
+ fn probe_failed(&mut self, path: &Path, short_channel_id: u64) {
+ self.0.probe_failed(path, short_channel_id)
+ }
+ fn probe_successful(&mut self, path: &Path) {
+ self.0.probe_successful(path)
+ }
+}
/// Proposed use of a channel passed as a parameter to [`Score::channel_penalty_msat`].
#[derive(Clone, Copy, Debug, PartialEq)]