@@ -260,16 +260,18 @@ impl ReadableArgs<u64> for FixedPenaltyScorer {
260
260
}
261
261
262
262
/// [`Score`] implementation that uses a dynamic penalty.
263
+ ///
264
+ /// (C-not exported)
263
265
pub struct DynamicPenaltyScorer < F >
264
266
where
265
- F : Fn ( u64 , u64 , u64 , & NodeId , & NodeId ) -> u64 ,
267
+ F : Fn ( u64 , & NodeId , & NodeId , ChannelUsage ) -> u64 ,
266
268
{
267
269
penalty_func : F ,
268
270
}
269
271
270
272
impl < F > DynamicPenaltyScorer < F >
271
273
where
272
- F : Fn ( u64 , u64 , u64 , & NodeId , & NodeId ) -> u64 ,
274
+ F : Fn ( u64 , & NodeId , & NodeId , ChannelUsage ) -> u64 ,
273
275
{
274
276
/// Creates a new scorer that applies a closure `penalty_func`, which takes the same arguments
275
277
/// as [`Score::channel_penalty_msat`].
@@ -281,12 +283,12 @@ where
281
283
282
284
impl < F > Score for DynamicPenaltyScorer < F >
283
285
where
284
- F : Fn ( u64 , u64 , u64 , & NodeId , & NodeId ) -> u64 ,
286
+ F : Fn ( u64 , & NodeId , & NodeId , ChannelUsage ) -> u64 ,
285
287
{
286
- fn channel_penalty_msat ( & self , short_channel_id : u64 , send_amt_msat : u64 , capacity_msat : u64 ,
287
- source : & NodeId , target : & NodeId ) -> u64
288
+ fn channel_penalty_msat ( & self , short_channel_id : u64 , source : & NodeId , target : & NodeId ,
289
+ usage : ChannelUsage ) -> u64
288
290
{
289
- ( self . penalty_func ) ( short_channel_id, send_amt_msat , capacity_msat , source, target)
291
+ ( self . penalty_func ) ( short_channel_id, source, target, usage )
290
292
}
291
293
292
294
fn payment_path_failed ( & mut self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { }
@@ -296,7 +298,7 @@ where
296
298
297
299
impl < F > Writeable for DynamicPenaltyScorer < F >
298
300
where
299
- F : Fn ( u64 , u64 , u64 , & NodeId , & NodeId ) -> u64 ,
301
+ F : Fn ( u64 , & NodeId , & NodeId , ChannelUsage ) -> u64 ,
300
302
{
301
303
#[ inline]
302
304
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
@@ -307,7 +309,7 @@ where
307
309
308
310
impl < F > ReadableArgs < F > for DynamicPenaltyScorer < F >
309
311
where
310
- F : Fn ( u64 , u64 , u64 , & NodeId , & NodeId ) -> u64 ,
312
+ F : Fn ( u64 , & NodeId , & NodeId , ChannelUsage ) -> u64 ,
311
313
{
312
314
#[ inline]
313
315
fn read < R : Read > ( r : & mut R , penalty_func : F ) -> Result < Self , DecodeError > {
0 commit comments