@@ -236,25 +236,20 @@ fn update_scorer<'a, S: 'static + Deref<Target = SC> + Send + Sync, SC: 'a + Wri
236
236
let mut score = scorer. lock ( ) ;
237
237
match event {
238
238
Event :: PaymentPathFailed { ref path, short_channel_id : Some ( scid) , .. } => {
239
- let path = path. iter ( ) . collect :: < Vec < _ > > ( ) ;
240
239
score. payment_path_failed ( & path, * scid) ;
241
240
} ,
242
241
Event :: PaymentPathFailed { ref path, payment_failed_permanently : true , .. } => {
243
242
// Reached if the destination explicitly failed it back. We treat this as a successful probe
244
243
// because the payment made it all the way to the destination with sufficient liquidity.
245
- let path = path. iter ( ) . collect :: < Vec < _ > > ( ) ;
246
244
score. probe_successful ( & path) ;
247
245
} ,
248
246
Event :: PaymentPathSuccessful { path, .. } => {
249
- let path = path. iter ( ) . collect :: < Vec < _ > > ( ) ;
250
247
score. payment_path_successful ( & path) ;
251
248
} ,
252
249
Event :: ProbeSuccessful { path, .. } => {
253
- let path = path. iter ( ) . collect :: < Vec < _ > > ( ) ;
254
250
score. probe_successful ( & path) ;
255
251
} ,
256
252
Event :: ProbeFailed { path, short_channel_id : Some ( scid) , .. } => {
257
- let path = path. iter ( ) . collect :: < Vec < _ > > ( ) ;
258
253
score. probe_failed ( & path, * scid) ;
259
254
} ,
260
255
_ => { } ,
@@ -751,7 +746,7 @@ mod tests {
751
746
use lightning:: ln:: msgs:: { ChannelMessageHandler , Init } ;
752
747
use lightning:: ln:: peer_handler:: { PeerManager , MessageHandler , SocketDescriptor , IgnoringMessageHandler } ;
753
748
use lightning:: routing:: gossip:: { NetworkGraph , NodeId , P2PGossipSync } ;
754
- use lightning:: routing:: router:: { DefaultRouter , RouteHop } ;
749
+ use lightning:: routing:: router:: { DefaultRouter , Path , RouteHop } ;
755
750
use lightning:: routing:: scoring:: { ChannelUsage , Score } ;
756
751
use lightning:: util:: config:: UserConfig ;
757
752
use lightning:: util:: ser:: Writeable ;
@@ -891,10 +886,10 @@ mod tests {
891
886
892
887
#[ derive( Debug ) ]
893
888
enum TestResult {
894
- PaymentFailure { path : Vec < RouteHop > , short_channel_id : u64 } ,
895
- PaymentSuccess { path : Vec < RouteHop > } ,
896
- ProbeFailure { path : Vec < RouteHop > } ,
897
- ProbeSuccess { path : Vec < RouteHop > } ,
889
+ PaymentFailure { path : Path , short_channel_id : u64 } ,
890
+ PaymentSuccess { path : Path } ,
891
+ ProbeFailure { path : Path } ,
892
+ ProbeSuccess { path : Path } ,
898
893
}
899
894
900
895
impl TestScorer {
@@ -916,11 +911,11 @@ mod tests {
916
911
& self , _short_channel_id : u64 , _source : & NodeId , _target : & NodeId , _usage : ChannelUsage
917
912
) -> u64 { unimplemented ! ( ) ; }
918
913
919
- fn payment_path_failed ( & mut self , actual_path : & [ & RouteHop ] , actual_short_channel_id : u64 ) {
914
+ fn payment_path_failed ( & mut self , actual_path : & Path , actual_short_channel_id : u64 ) {
920
915
if let Some ( expectations) = & mut self . event_expectations {
921
916
match expectations. pop_front ( ) . unwrap ( ) {
922
917
TestResult :: PaymentFailure { path, short_channel_id } => {
923
- assert_eq ! ( actual_path, & path. iter ( ) . collect :: < Vec <_>> ( ) [ .. ] ) ;
918
+ assert_eq ! ( actual_path, & path) ;
924
919
assert_eq ! ( actual_short_channel_id, short_channel_id) ;
925
920
} ,
926
921
TestResult :: PaymentSuccess { path } => {
@@ -936,14 +931,14 @@ mod tests {
936
931
}
937
932
}
938
933
939
- fn payment_path_successful ( & mut self , actual_path : & [ & RouteHop ] ) {
934
+ fn payment_path_successful ( & mut self , actual_path : & Path ) {
940
935
if let Some ( expectations) = & mut self . event_expectations {
941
936
match expectations. pop_front ( ) . unwrap ( ) {
942
937
TestResult :: PaymentFailure { path, .. } => {
943
938
panic ! ( "Unexpected payment path failure: {:?}" , path)
944
939
} ,
945
940
TestResult :: PaymentSuccess { path } => {
946
- assert_eq ! ( actual_path, & path. iter ( ) . collect :: < Vec <_>> ( ) [ .. ] ) ;
941
+ assert_eq ! ( actual_path, & path) ;
947
942
} ,
948
943
TestResult :: ProbeFailure { path } => {
949
944
panic ! ( "Unexpected probe failure: {:?}" , path)
@@ -955,7 +950,7 @@ mod tests {
955
950
}
956
951
}
957
952
958
- fn probe_failed ( & mut self , actual_path : & [ & RouteHop ] , _: u64 ) {
953
+ fn probe_failed ( & mut self , actual_path : & Path , _: u64 ) {
959
954
if let Some ( expectations) = & mut self . event_expectations {
960
955
match expectations. pop_front ( ) . unwrap ( ) {
961
956
TestResult :: PaymentFailure { path, .. } => {
@@ -965,15 +960,15 @@ mod tests {
965
960
panic ! ( "Unexpected payment path success: {:?}" , path)
966
961
} ,
967
962
TestResult :: ProbeFailure { path } => {
968
- assert_eq ! ( actual_path, & path. iter ( ) . collect :: < Vec <_>> ( ) [ .. ] ) ;
963
+ assert_eq ! ( actual_path, & path) ;
969
964
} ,
970
965
TestResult :: ProbeSuccess { path } => {
971
966
panic ! ( "Unexpected probe success: {:?}" , path)
972
967
}
973
968
}
974
969
}
975
970
}
976
- fn probe_successful ( & mut self , actual_path : & [ & RouteHop ] ) {
971
+ fn probe_successful ( & mut self , actual_path : & Path ) {
977
972
if let Some ( expectations) = & mut self . event_expectations {
978
973
match expectations. pop_front ( ) . unwrap ( ) {
979
974
TestResult :: PaymentFailure { path, .. } => {
@@ -986,7 +981,7 @@ mod tests {
986
981
panic ! ( "Unexpected probe failure: {:?}" , path)
987
982
} ,
988
983
TestResult :: ProbeSuccess { path } => {
989
- assert_eq ! ( actual_path, & path. iter ( ) . collect :: < Vec <_>> ( ) [ .. ] ) ;
984
+ assert_eq ! ( actual_path, & path) ;
990
985
}
991
986
}
992
987
}
@@ -1510,14 +1505,14 @@ mod tests {
1510
1505
let node_1_privkey = SecretKey :: from_slice( & [ 42 ; 32 ] ) . unwrap( ) ;
1511
1506
let node_1_id = PublicKey :: from_secret_key( & secp_ctx, & node_1_privkey) ;
1512
1507
1513
- let path = vec![ RouteHop {
1508
+ let path = Path { hops : vec![ RouteHop {
1514
1509
pubkey: node_1_id,
1515
1510
node_features: NodeFeatures :: empty( ) ,
1516
1511
short_channel_id: scored_scid,
1517
1512
channel_features: ChannelFeatures :: empty( ) ,
1518
1513
fee_msat: 0 ,
1519
1514
cltv_expiry_delta: MIN_CLTV_EXPIRY_DELTA as u32 ,
1520
- } ] ;
1515
+ } ] , blinded_tail : None } ;
1521
1516
1522
1517
$nodes[ 0 ] . scorer. lock( ) . unwrap( ) . expect( TestResult :: PaymentFailure { path: path. clone( ) , short_channel_id: scored_scid } ) ;
1523
1518
$nodes[ 0 ] . node. push_pending_event( Event :: PaymentPathFailed {
0 commit comments