@@ -5,7 +5,7 @@ use crate::payment::Payer;
55
66use crate :: { prelude:: * , Description , InvoiceDescription , Sha256 } ;
77use bech32:: ToBase32 ;
8- use bitcoin_hashes:: { Hash , sha256 } ;
8+ use bitcoin_hashes:: Hash ;
99use lightning:: chain;
1010use lightning:: chain:: chaininterface:: { BroadcasterInterface , FeeEstimator } ;
1111use lightning:: chain:: keysinterface:: { Recipient , KeysInterface } ;
@@ -14,15 +14,12 @@ use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, PaymentId, P
1414#[ cfg( feature = "std" ) ]
1515use lightning:: ln:: channelmanager:: { PhantomRouteHints , MIN_CLTV_EXPIRY_DELTA } ;
1616use lightning:: ln:: inbound_payment:: { create, create_from_hash, ExpandedKey } ;
17- use lightning:: ln:: msgs:: LightningError ;
18- use lightning:: routing:: gossip:: { NetworkGraph , RoutingFees } ;
19- use lightning:: routing:: router:: { InFlightHtlcs , Route , RouteHint , RouteHintHop , RouteParameters , find_route, RouteHop , Router } ;
20- use lightning:: routing:: scoring:: { LockableScore , Score , ScorerAccountingForInFlightHtlcs } ;
17+ use lightning:: routing:: gossip:: RoutingFees ;
18+ use lightning:: routing:: router:: { InFlightHtlcs , Route , RouteHint , RouteHintHop } ;
2119use lightning:: util:: logger:: Logger ;
2220use secp256k1:: PublicKey ;
2321use core:: ops:: Deref ;
2422use core:: time:: Duration ;
25- use crate :: sync:: Mutex ;
2623
2724#[ cfg( feature = "std" ) ]
2825/// Utility to create an invoice that can be paid to one of multiple nodes, or a "phantom invoice."
@@ -524,67 +521,6 @@ fn filter_channels<L: Deref>(
524521 . collect :: < Vec < RouteHint > > ( )
525522}
526523
527- /// A [`Router`] implemented using [`find_route`].
528- pub struct DefaultRouter < G : Deref < Target = NetworkGraph < L > > , L : Deref , S : Deref > where
529- L :: Target : Logger ,
530- S :: Target : for < ' a > LockableScore < ' a > ,
531- {
532- network_graph : G ,
533- logger : L ,
534- random_seed_bytes : Mutex < [ u8 ; 32 ] > ,
535- scorer : S
536- }
537-
538- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , S : Deref > DefaultRouter < G , L , S > where
539- L :: Target : Logger ,
540- S :: Target : for < ' a > LockableScore < ' a > ,
541- {
542- /// Creates a new router using the given [`NetworkGraph`], a [`Logger`], and a randomness source
543- /// `random_seed_bytes`.
544- pub fn new ( network_graph : G , logger : L , random_seed_bytes : [ u8 ; 32 ] , scorer : S ) -> Self {
545- let random_seed_bytes = Mutex :: new ( random_seed_bytes) ;
546- Self { network_graph, logger, random_seed_bytes, scorer }
547- }
548- }
549-
550- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , S : Deref > Router for DefaultRouter < G , L , S > where
551- L :: Target : Logger ,
552- S :: Target : for < ' a > LockableScore < ' a > ,
553- {
554- fn find_route (
555- & self , payer : & PublicKey , params : & RouteParameters , first_hops : Option < & [ & ChannelDetails ] > ,
556- inflight_htlcs : InFlightHtlcs
557- ) -> Result < Route , LightningError > {
558- let random_seed_bytes = {
559- let mut locked_random_seed_bytes = self . random_seed_bytes . lock ( ) . unwrap ( ) ;
560- * locked_random_seed_bytes = sha256:: Hash :: hash ( & * locked_random_seed_bytes) . into_inner ( ) ;
561- * locked_random_seed_bytes
562- } ;
563-
564- find_route (
565- payer, params, & self . network_graph , first_hops, & * self . logger ,
566- & ScorerAccountingForInFlightHtlcs :: new ( & mut self . scorer . lock ( ) , inflight_htlcs) ,
567- & random_seed_bytes
568- )
569- }
570-
571- fn notify_payment_path_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) {
572- self . scorer . lock ( ) . payment_path_failed ( path, short_channel_id) ;
573- }
574-
575- fn notify_payment_path_successful ( & self , path : & [ & RouteHop ] ) {
576- self . scorer . lock ( ) . payment_path_successful ( path) ;
577- }
578-
579- fn notify_payment_probe_successful ( & self , path : & [ & RouteHop ] ) {
580- self . scorer . lock ( ) . probe_successful ( path) ;
581- }
582-
583- fn notify_payment_probe_failed ( & self , path : & [ & RouteHop ] , short_channel_id : u64 ) {
584- self . scorer . lock ( ) . probe_failed ( path, short_channel_id) ;
585- }
586- }
587-
588524impl < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > Payer for ChannelManager < M , T , K , F , L >
589525where
590526 M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
0 commit comments