@@ -13,7 +13,6 @@ use chain::chaininterface::{ChainError, ChainWatchInterface};
13
13
use ln:: features:: { ChannelFeatures , NodeFeatures } ;
14
14
use ln:: msgs:: { DecodeError , ErrorAction , LightningError , RoutingMessageHandler , NetAddress } ;
15
15
use ln:: msgs;
16
- use routing:: router:: RouteHop ;
17
16
use util:: ser:: { Writeable , Readable , Writer } ;
18
17
use util:: logger:: Logger ;
19
18
@@ -428,15 +427,30 @@ impl Readable for NodeInfo {
428
427
}
429
428
}
430
429
431
- /// Users store custom channel metadata separately. This trait is implemented by users, so that NetworkGraph
432
- /// objects can call into them to update the metadata and retrieve a minimum fee penalty when doing the
433
- /// route-finding algorithm.
430
+ /// Represents custom methods used to update channel scores based on user stored metadata. By
431
+ /// default, these methods do nothing. Users may customize these methods.
432
+ pub trait ScoreProducer {
433
+ /// Default method for tracking PaymentFailed events
434
+ fn score_payment_failure ( & self ) { }
435
+ /// Default method for tracking PaymentSent events
436
+ fn score_payment_success ( & self ) { }
437
+ }
438
+
439
+ /// Users store custom channel metadata separately. This trait is implemented by users, who may use
440
+ /// the NetworkGraph to update whatever metadata they are storing about their view of the network.
434
441
pub trait ChannelScorer {
435
442
/// Holds information about a given channel that is to be updated when the user wishes to update
436
443
/// the metadata they are tracking (eg metrics for reliability, uptime, floppiness, etc.)
437
444
type Metadata ;
438
- /// Returns penalty fee for a given channel ID based on user's channel metadata
439
- fn calculate_minimum_fee_penalty ( & self , _channel_id : u64 ) -> u64 { 0 }
445
+ /// Any struct that implements the ScoreProducer trait. By default, these methods do not do
446
+ /// anything, but a user could create a list of customized ScorerProducers that implement select
447
+ /// methods of a given trait.
448
+ type ScorerProducer : ScoreProducer ;
449
+ /// Return score for a given channel by using user-defined channel_scorers
450
+ fn calculate_minimum_fee_penalty ( & self , channel_scorers : Vec < Self :: ScorerProducer > , channel : Self :: Metadata ) -> u64 ;
451
+ /// Adds a ScoreProducer struct to user metadata. These are overriden customizations of the
452
+ /// default methods provided by rust-lightning.
453
+ fn add_scorer_producer ( & self , score_producer : Self :: ScorerProducer ) ;
440
454
}
441
455
442
456
/// Represents the network as nodes and channels between them
0 commit comments