Skip to content

Commit 087c8f6

Browse files
committed
Avoid blanket impls in bindings builds
The C bindings implements `Deref` for all traits, so having a blanket `Deref` implementation ends up conflicting with this.
1 parent 0bc0de4 commit 087c8f6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lightning/src/routing/scoring.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ pub trait Score : ScoreLookUp + ScoreUpdate $(+ $supertrait)* {}
133133
#[cfg(not(c_bindings))]
134134
impl<T: ScoreLookUp + ScoreUpdate $(+ $supertrait)*> Score for T {}
135135

136+
#[cfg(not(c_bindings))]
136137
impl<S: ScoreLookUp, T: Deref<Target=S>> ScoreLookUp for T {
137138
type ScoreParams = S::ScoreParams;
138139
fn channel_penalty_msat(
@@ -142,6 +143,7 @@ impl<S: ScoreLookUp, T: Deref<Target=S>> ScoreLookUp for T {
142143
}
143144
}
144145

146+
#[cfg(not(c_bindings))]
145147
impl<S: ScoreUpdate, T: DerefMut<Target=S>> ScoreUpdate for T {
146148
fn payment_path_failed(&mut self, path: &Path, short_channel_id: u64) {
147149
self.deref_mut().payment_path_failed(path, short_channel_id)
@@ -310,6 +312,16 @@ impl<'a, T: 'a + Score> Deref for MultiThreadedScoreLockRead<'a, T> {
310312
}
311313
}
312314

315+
#[cfg(c_bindings)]
316+
impl<'a, T: Score> ScoreLookUp for MultiThreadedScoreLockRead<'a, T> {
317+
type ScoreParams = T::ScoreParams;
318+
fn channel_penalty_msat(&self, short_channel_id: u64, source: &NodeId,
319+
target: &NodeId, usage: ChannelUsage, score_params: &Self::ScoreParams
320+
) -> u64 {
321+
self.0.channel_penalty_msat(short_channel_id, source, target, usage, score_params)
322+
}
323+
}
324+
313325
#[cfg(c_bindings)]
314326
impl<'a, T: Score> Writeable for MultiThreadedScoreLockWrite<'a, T> {
315327
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
@@ -333,6 +345,25 @@ impl<'a, T: 'a + Score> DerefMut for MultiThreadedScoreLockWrite<'a, T> {
333345
}
334346
}
335347

348+
#[cfg(c_bindings)]
349+
impl<'a, T: Score> ScoreUpdate for MultiThreadedScoreLockWrite<'a, T> {
350+
fn payment_path_failed(&mut self, path: &Path, short_channel_id: u64) {
351+
self.0.payment_path_failed(path, short_channel_id)
352+
}
353+
354+
fn payment_path_successful(&mut self, path: &Path) {
355+
self.0.payment_path_successful(path)
356+
}
357+
358+
fn probe_failed(&mut self, path: &Path, short_channel_id: u64) {
359+
self.0.probe_failed(path, short_channel_id)
360+
}
361+
362+
fn probe_successful(&mut self, path: &Path) {
363+
self.0.probe_successful(path)
364+
}
365+
}
366+
336367

337368
/// Proposed use of a channel passed as a parameter to [`ScoreLookUp::channel_penalty_msat`].
338369
#[derive(Clone, Copy, Debug, PartialEq)]

0 commit comments

Comments
 (0)