@@ -435,12 +435,15 @@ impl Readable for NodeInfo {
435
435
/// objects can call into them to update the metadata and retrieve a minimum fee penalty when doing the
436
436
/// route-finding algorithm.
437
437
pub trait ChannelScorer {
438
+ /// Holds information about a given channel that is to be updated when the user wishes to update
439
+ /// the metadata they are tracking (eg metrics for reliability, uptime, floppiness, etc.)
440
+ type Metadata ;
438
441
/// Returns penalty fee for a given channel ID based on user's channel metadata
439
- fn calculate_minimum_fee_penalty ( & self , _channel_id : u64 ) { }
442
+ fn calculate_minimum_fee_penalty ( & self , _channel_id : u64 ) -> Option < u64 > { None }
440
443
/// Optional: allows user to count PaymentSent events for channels
441
- fn score_payment_success ( & self , _route : Vec < Vec < RouteHop > > ) { }
444
+ fn score_payment_success ( & self , _route : Vec < Vec < RouteHop > > , _metadata : Vec < Self :: Metadata > ) { }
442
445
/// Optional: allows user to count PaymentFailed events for channels
443
- fn score_payment_failure ( & self , _route : Vec < Vec < RouteHop > > , _faulty_nodes : Vec < PublicKey > ) { }
446
+ fn score_payment_failure ( & self , _route : Vec < Vec < RouteHop > > , _faulty_nodes : Vec < PublicKey > , _metadata : Vec < Self :: Metadata > ) { }
444
447
}
445
448
446
449
/// Represents the network as nodes and channels between them
@@ -503,7 +506,12 @@ impl std::fmt::Display for NetworkGraph {
503
506
}
504
507
}
505
508
506
- impl ChannelScorer for NetworkGraph { }
509
+ /// By default, just do nothing when scoring channels. A user is free to extend these
510
+ /// definitions to meet their needs.
511
+ impl ChannelScorer for NetworkGraph {
512
+ /// The default type for Metadata is just a placeholder.
513
+ type Metadata = Option < u8 > ;
514
+ }
507
515
508
516
impl NetworkGraph {
509
517
/// Returns all known valid channels' short ids along with announced channel info.
0 commit comments