@@ -506,8 +506,8 @@ where
506
506
I : ExactSizeIterator < Item = ForwardNode > ,
507
507
T : secp256k1:: Signing + secp256k1:: Verification
508
508
> (
509
- & self , recipient : PublicKey , context : MessageContext , peers : I ,
510
- secp_ctx : & Secp256k1 < T > , compact_paths : bool
509
+ network_graph : & G , recipient : PublicKey , context : MessageContext , peers : I ,
510
+ entropy_source : & ES , secp_ctx : & Secp256k1 < T > , compact_paths : bool ,
511
511
) -> Result < Vec < BlindedPath > , ( ) > {
512
512
// Limit the number of blinded paths that are computed.
513
513
const MAX_PATHS : usize = 3 ;
@@ -516,7 +516,7 @@ where
516
516
// recipient's node_id.
517
517
const MIN_PEER_CHANNELS : usize = 3 ;
518
518
519
- let network_graph = self . network_graph . deref ( ) . read_only ( ) ;
519
+ let network_graph = network_graph. deref ( ) . read_only ( ) ;
520
520
let is_recipient_announced =
521
521
network_graph. nodes ( ) . contains_key ( & NodeId :: from_pubkey ( & recipient) ) ;
522
522
@@ -546,7 +546,7 @@ where
546
546
547
547
let paths = peer_info. into_iter ( )
548
548
. map ( |( peer, _, _) | {
549
- BlindedPath :: new_for_message ( & [ peer] , recipient, context. clone ( ) , & * self . entropy_source , secp_ctx)
549
+ BlindedPath :: new_for_message ( & [ peer] , recipient, context. clone ( ) , & * * entropy_source, secp_ctx)
550
550
} )
551
551
. take ( MAX_PATHS )
552
552
. collect :: < Result < Vec < _ > , _ > > ( ) ;
@@ -555,7 +555,7 @@ where
555
555
Ok ( paths) if !paths. is_empty ( ) => Ok ( paths) ,
556
556
_ => {
557
557
if is_recipient_announced {
558
- BlindedPath :: one_hop_for_message ( recipient, context, & * self . entropy_source , secp_ctx)
558
+ BlindedPath :: one_hop_for_message ( recipient, context, & * * entropy_source, secp_ctx)
559
559
. map ( |path| vec ! [ path] )
560
560
} else {
561
561
Err ( ( ) )
@@ -571,17 +571,11 @@ where
571
571
572
572
Ok ( paths)
573
573
}
574
- }
575
574
576
- impl < G : Deref < Target =NetworkGraph < L > > , L : Deref , ES : Deref > MessageRouter for DefaultMessageRouter < G , L , ES >
577
- where
578
- L :: Target : Logger ,
579
- ES :: Target : EntropySource ,
580
- {
581
- fn find_path (
582
- & self , sender : PublicKey , peers : Vec < PublicKey > , mut destination : Destination
575
+ pub ( crate ) fn find_path (
576
+ network_graph : & G , sender : PublicKey , peers : Vec < PublicKey > , mut destination : Destination
583
577
) -> Result < OnionMessagePath , ( ) > {
584
- let network_graph = self . network_graph . deref ( ) . read_only ( ) ;
578
+ let network_graph = network_graph. deref ( ) . read_only ( ) ;
585
579
destination. resolve ( & network_graph) ;
586
580
587
581
let first_node = match destination. first_node ( ) {
@@ -611,26 +605,55 @@ where
611
605
}
612
606
}
613
607
614
- fn create_blinded_paths <
608
+ pub ( crate ) fn create_blinded_paths <
615
609
T : secp256k1:: Signing + secp256k1:: Verification
616
610
> (
617
- & self , recipient : PublicKey , context : MessageContext ,
618
- peers : Vec < PublicKey > , secp_ctx : & Secp256k1 < T > ,
611
+ network_graph : & G , recipient : PublicKey , context : MessageContext ,
612
+ peers : Vec < PublicKey > , entropy_source : & ES , secp_ctx : & Secp256k1 < T > ,
619
613
) -> Result < Vec < BlindedPath > , ( ) > {
620
614
let peers = peers
621
615
. into_iter ( )
622
616
. map ( |node_id| ForwardNode { node_id, short_channel_id : None } ) ;
623
- self . create_blinded_paths_from_iter ( recipient, context, peers, secp_ctx, false )
617
+ Self :: create_blinded_paths_from_iter ( network_graph, recipient, context, peers. into_iter ( ) , entropy_source, secp_ctx, false )
618
+ }
619
+
620
+ pub ( crate ) fn create_compact_blinded_paths <
621
+ T : secp256k1:: Signing + secp256k1:: Verification
622
+ > (
623
+ network_graph : & G , recipient : PublicKey , context : MessageContext ,
624
+ peers : Vec < ForwardNode > , entropy_source : & ES , secp_ctx : & Secp256k1 < T > ,
625
+ ) -> Result < Vec < BlindedPath > , ( ) > {
626
+ Self :: create_blinded_paths_from_iter ( network_graph, recipient, context, peers. into_iter ( ) , entropy_source, secp_ctx, true )
627
+ }
628
+ }
629
+
630
+ impl < G : Deref < Target =NetworkGraph < L > > , L : Deref , ES : Deref > MessageRouter for DefaultMessageRouter < G , L , ES >
631
+ where
632
+ L :: Target : Logger ,
633
+ ES :: Target : EntropySource ,
634
+ {
635
+ fn find_path (
636
+ & self , sender : PublicKey , peers : Vec < PublicKey > , destination : Destination
637
+ ) -> Result < OnionMessagePath , ( ) > {
638
+ Self :: find_path ( & self . network_graph , sender, peers, destination)
639
+ }
640
+
641
+ fn create_blinded_paths <
642
+ T : secp256k1:: Signing + secp256k1:: Verification
643
+ > (
644
+ & self , recipient : PublicKey , context : MessageContext , peers : Vec < PublicKey > , secp_ctx : & Secp256k1 < T > ,
645
+ ) -> Result < Vec < BlindedPath > , ( ) > {
646
+ Self :: create_blinded_paths ( & self . network_graph , recipient, context, peers, & self . entropy_source , secp_ctx)
624
647
}
625
648
626
649
fn create_compact_blinded_paths <
627
650
T : secp256k1:: Signing + secp256k1:: Verification
628
651
> (
629
- & self , recipient : PublicKey , context : MessageContext ,
630
- peers : Vec < ForwardNode > , secp_ctx : & Secp256k1 < T > ,
652
+ & self , recipient : PublicKey , context : MessageContext , peers : Vec < ForwardNode > , secp_ctx : & Secp256k1 < T > ,
631
653
) -> Result < Vec < BlindedPath > , ( ) > {
632
- self . create_blinded_paths_from_iter ( recipient, context, peers. into_iter ( ) , secp_ctx , true )
654
+ Self :: create_compact_blinded_paths ( & self . network_graph , recipient, context, peers, & self . entropy_source , secp_ctx )
633
655
}
656
+
634
657
}
635
658
636
659
/// A path for sending an [`OnionMessage`].
0 commit comments