@@ -282,6 +282,12 @@ impl_writeable!(ChannelInfo, 0, {
282
282
minimum_fee_penalty
283
283
} ) ;
284
284
285
+ /// By default, these methods do nothing. A user may override them to write to their metadata as needed
286
+ impl ChannelScorer for ChannelInfo {
287
+ fn calculate_minimum_fee_penalty ( & self , channel_id : u64 ) { }
288
+ fn score_payment_failure ( & self , route : Vec < Vec < RouteHop > > , faulty_nodes : Vec < PublicKey > ) { }
289
+ fn score_payment_success ( & self , route : Vec < Vec < RouteHop > > ) { }
290
+ }
285
291
286
292
/// Fees for routing via a given channel or a node
287
293
#[ derive( Eq , PartialEq , Copy , Clone , Debug ) ]
@@ -437,7 +443,7 @@ impl Readable for NodeInfo {
437
443
/// route-finding algorithm.
438
444
pub trait ChannelScorer {
439
445
/// Returns penalty fee for a given channel ID based on user's channel metadata
440
- fn calculate_minimum_fee_penalty ( & self , channel_id : u64 ) -> u64 ;
446
+ fn calculate_minimum_fee_penalty ( & self , channel_id : u64 ) ;
441
447
/// Optional: allows user to count PaymentSent events for channels
442
448
fn score_payment_success ( & self , route : Vec < Vec < RouteHop > > ) ;
443
449
/// Optional: allows user to count PaymentFailed events for channels
@@ -504,6 +510,12 @@ impl std::fmt::Display for NetworkGraph {
504
510
}
505
511
}
506
512
513
+ impl ChannelScorer for NetworkGraph {
514
+ fn calculate_minimum_fee_penalty ( & self , channel_id : u64 ) { }
515
+ fn score_payment_success ( & self , route : Vec < Vec < RouteHop > > ) { }
516
+ fn score_payment_failure ( & self , route : Vec < Vec < RouteHop > > , faulty_nodes : Vec < PublicKey > ) { }
517
+ }
518
+
507
519
impl NetworkGraph {
508
520
/// Returns all known valid channels' short ids along with announced channel info.
509
521
pub fn get_channels < ' a > ( & ' a self ) -> & ' a BTreeMap < u64 , ChannelInfo > { & self . channels }
0 commit comments