@@ -15,9 +15,9 @@ use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, PaymentId, P
1515use lightning:: ln:: channelmanager:: { PhantomRouteHints , MIN_CLTV_EXPIRY_DELTA } ;
1616use lightning:: ln:: inbound_payment:: { create, create_from_hash, ExpandedKey } ;
1717use lightning:: ln:: msgs:: LightningError ;
18- use lightning:: routing:: gossip:: { NetworkGraph , NodeId , RoutingFees } ;
18+ use lightning:: routing:: gossip:: { NetworkGraph , RoutingFees } ;
1919use lightning:: routing:: router:: { InFlightHtlcs , Route , RouteHint , RouteHintHop , RouteParameters , find_route, RouteHop , Router } ;
20- use lightning:: routing:: scoring:: { ChannelUsage , LockableScore , Score } ;
20+ use lightning:: routing:: scoring:: { LockableScore , Score , ScorerAccountingForInFlightHtlcs } ;
2121use lightning:: util:: logger:: Logger ;
2222use secp256k1:: PublicKey ;
2323use core:: ops:: Deref ;
@@ -627,54 +627,6 @@ where
627627 fn inflight_htlcs ( & self ) -> InFlightHtlcs { self . compute_inflight_htlcs ( ) }
628628}
629629
630-
631- /// Used to store information about all the HTLCs that are inflight across all payment attempts.
632- pub ( crate ) struct ScorerAccountingForInFlightHtlcs < ' a , S : Score > {
633- scorer : & ' a mut S ,
634- /// Maps a channel's short channel id and its direction to the liquidity used up.
635- inflight_htlcs : InFlightHtlcs ,
636- }
637-
638- impl < ' a , S : Score > ScorerAccountingForInFlightHtlcs < ' a , S > {
639- pub ( crate ) fn new ( scorer : & ' a mut S , inflight_htlcs : InFlightHtlcs ) -> Self {
640- ScorerAccountingForInFlightHtlcs {
641- scorer,
642- inflight_htlcs
643- }
644- }
645- }
646-
647- #[ cfg( c_bindings) ]
648- impl < ' a , S : Score > lightning:: util:: ser:: Writeable for ScorerAccountingForInFlightHtlcs < ' a , S > {
649- fn write < W : lightning:: util:: ser:: Writer > ( & self , writer : & mut W ) -> Result < ( ) , lightning:: io:: Error > { self . scorer . write ( writer) }
650- }
651-
652- impl < ' a , S : Score > Score for ScorerAccountingForInFlightHtlcs < ' a , S > {
653- fn channel_penalty_msat ( & self , short_channel_id : u64 , source : & NodeId , target : & NodeId , usage : ChannelUsage ) -> u64 {
654- if let Some ( used_liquidity) = self . inflight_htlcs . used_liquidity_msat (
655- source, target, short_channel_id
656- ) {
657- let usage = ChannelUsage {
658- inflight_htlc_msat : usage. inflight_htlc_msat + used_liquidity,
659- ..usage
660- } ;
661-
662- self . scorer . channel_penalty_msat ( short_channel_id, source, target, usage)
663- } else {
664- self . scorer . channel_penalty_msat ( short_channel_id, source, target, usage)
665- }
666- }
667-
668- fn payment_path_failed ( & mut self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { unreachable ! ( ) }
669-
670- fn payment_path_successful ( & mut self , _path : & [ & RouteHop ] ) { unreachable ! ( ) }
671-
672- fn probe_failed ( & mut self , _path : & [ & RouteHop ] , _short_channel_id : u64 ) { unreachable ! ( ) }
673-
674- fn probe_successful ( & mut self , _path : & [ & RouteHop ] ) { unreachable ! ( ) }
675- }
676-
677-
678630#[ cfg( test) ]
679631mod test {
680632 use core:: time:: Duration ;
0 commit comments