@@ -1251,9 +1251,6 @@ fn iter_equal<I1: Iterator, I2: Iterator>(mut iter_a: I1, mut iter_b: I2)
1251
1251
/// These fee values are useful to choose hops as we traverse the graph "payee-to-payer".
1252
1252
#[ derive( Clone ) ]
1253
1253
pub struct PathBuildingHop < ' a > {
1254
- // Note that this should be dropped in favor of loading it from CandidateRouteHop, but doing so
1255
- // is a larger refactor and will require careful performance analysis.
1256
- node_id : NodeId ,
1257
1254
candidate : CandidateRouteHop < ' a > ,
1258
1255
fee_msat : u64 ,
1259
1256
@@ -1291,7 +1288,7 @@ impl<'a> core::fmt::Debug for PathBuildingHop<'a> {
1291
1288
fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> Result < ( ) , core:: fmt:: Error > {
1292
1289
let mut debug_struct = f. debug_struct ( "PathBuildingHop" ) ;
1293
1290
debug_struct
1294
- . field ( "node_id" , & self . node_id )
1291
+ . field ( "node_id" , & self . candidate . target ( ) )
1295
1292
. field ( "short_channel_id" , & self . candidate . short_channel_id ( ) )
1296
1293
. field ( "total_fee_msat" , & self . total_fee_msat )
1297
1294
. field ( "next_hops_fee_msat" , & self . next_hops_fee_msat )
@@ -1944,7 +1941,6 @@ where L::Target: Logger {
1944
1941
// This will affect our decision on selecting short_channel_id
1945
1942
// as a way to reach the $dest_node_id.
1946
1943
PathBuildingHop {
1947
- node_id: $dest_node_id. clone( ) ,
1948
1944
candidate: $candidate. clone( ) ,
1949
1945
fee_msat: 0 ,
1950
1946
next_hops_fee_msat: u64 :: max_value( ) ,
@@ -2034,7 +2030,6 @@ where L::Target: Logger {
2034
2030
old_entry. next_hops_fee_msat = $next_hops_fee_msat;
2035
2031
old_entry. hop_use_fee_msat = hop_use_fee_msat;
2036
2032
old_entry. total_fee_msat = total_fee_msat;
2037
- old_entry. node_id = $dest_node_id. clone( ) ;
2038
2033
old_entry. candidate = $candidate. clone( ) ;
2039
2034
old_entry. fee_msat = 0 ; // This value will be later filled with hop_use_fee_msat of the following channel
2040
2035
old_entry. path_htlc_minimum_msat = path_htlc_minimum_msat;
@@ -2404,7 +2399,7 @@ where L::Target: Logger {
2404
2399
2405
2400
' path_walk: loop {
2406
2401
let mut features_set = false ;
2407
- if let Some ( first_channels) = first_hop_targets. get ( & ordered_hops. last ( ) . unwrap ( ) . 0 . node_id ) {
2402
+ if let Some ( first_channels) = first_hop_targets. get ( & ordered_hops. last ( ) . unwrap ( ) . 0 . candidate . target ( ) ) {
2408
2403
for details in first_channels {
2409
2404
if let Some ( scid) = ordered_hops. last ( ) . unwrap ( ) . 0 . candidate . short_channel_id ( ) {
2410
2405
if details. get_outbound_payment_scid ( ) . unwrap ( ) == scid {
@@ -2416,7 +2411,7 @@ where L::Target: Logger {
2416
2411
}
2417
2412
}
2418
2413
if !features_set {
2419
- if let Some ( node) = network_nodes. get ( & ordered_hops. last ( ) . unwrap ( ) . 0 . node_id ) {
2414
+ if let Some ( node) = network_nodes. get ( & ordered_hops. last ( ) . unwrap ( ) . 0 . candidate . target ( ) ) {
2420
2415
if let Some ( node_info) = node. announcement_info . as_ref ( ) {
2421
2416
ordered_hops. last_mut ( ) . unwrap ( ) . 1 = node_info. features . clone ( ) ;
2422
2417
} else {
@@ -2433,11 +2428,11 @@ where L::Target: Logger {
2433
2428
// save this path for the payment route. Also, update the liquidity
2434
2429
// remaining on the used hops, so that we take them into account
2435
2430
// while looking for more paths.
2436
- if ordered_hops. last ( ) . unwrap ( ) . 0 . node_id == maybe_dummy_payee_node_id {
2431
+ if ordered_hops. last ( ) . unwrap ( ) . 0 . candidate . target ( ) == maybe_dummy_payee_node_id {
2437
2432
break ' path_walk;
2438
2433
}
2439
2434
2440
- new_entry = match dist. remove ( & ordered_hops. last ( ) . unwrap ( ) . 0 . node_id ) {
2435
+ new_entry = match dist. remove ( & ordered_hops. last ( ) . unwrap ( ) . 0 . candidate . target ( ) ) {
2441
2436
Some ( payment_hop) => payment_hop,
2442
2437
// We can't arrive at None because, if we ever add an entry to targets,
2443
2438
// we also fill in the entry in dist (see add_entry!).
@@ -2476,12 +2471,13 @@ where L::Target: Logger {
2476
2471
// Remember that we used these channels so that we don't rely
2477
2472
// on the same liquidity in future paths.
2478
2473
let mut prevented_redundant_path_selection = false ;
2479
- let prev_hop_iter = core:: iter:: once ( & our_node_id)
2480
- . chain ( payment_path. hops . iter ( ) . map ( |( hop, _) | & hop. node_id ) ) ;
2474
+ let prev_hop_iter = core:: iter:: once ( our_node_id)
2475
+ . chain ( payment_path. hops . iter ( ) . map ( |( hop, _) | hop. candidate . target ( ) ) ) ;
2481
2476
for ( prev_hop, ( hop, _) ) in prev_hop_iter. zip ( payment_path. hops . iter ( ) ) {
2477
+ let target = hop. candidate . target ( ) ;
2482
2478
let spent_on_hop_msat = value_contribution_msat + hop. next_hops_fee_msat ;
2483
2479
let used_liquidity_msat = used_liquidities
2484
- . entry ( hop. candidate . id ( * prev_hop < hop . node_id ) )
2480
+ . entry ( hop. candidate . id ( prev_hop < target ) )
2485
2481
. and_modify ( |used_liquidity_msat| * used_liquidity_msat += spent_on_hop_msat)
2486
2482
. or_insert ( spent_on_hop_msat) ;
2487
2483
let hop_capacity = hop. candidate . effective_capacity ( ) ;
@@ -2656,8 +2652,8 @@ where L::Target: Logger {
2656
2652
} ) ;
2657
2653
for idx in 0 ..( selected_route. len ( ) - 1 ) {
2658
2654
if idx + 1 >= selected_route. len ( ) { break ; }
2659
- if iter_equal ( selected_route[ idx ] . hops . iter ( ) . map ( |h| ( h. 0 . candidate . id ( true ) , h. 0 . node_id ) ) ,
2660
- selected_route[ idx + 1 ] . hops . iter ( ) . map ( |h| ( h. 0 . candidate . id ( true ) , h. 0 . node_id ) ) ) {
2655
+ if iter_equal ( selected_route[ idx ] . hops . iter ( ) . map ( |h| ( h. 0 . candidate . id ( true ) , h. 0 . candidate . target ( ) ) ) ,
2656
+ selected_route[ idx + 1 ] . hops . iter ( ) . map ( |h| ( h. 0 . candidate . id ( true ) , h. 0 . candidate . target ( ) ) ) ) {
2661
2657
let new_value = selected_route[ idx] . get_value_msat ( ) + selected_route[ idx + 1 ] . get_value_msat ( ) ;
2662
2658
selected_route[ idx] . update_value_and_recompute_fees ( new_value) ;
2663
2659
selected_route. remove ( idx + 1 ) ;
@@ -2682,14 +2678,14 @@ where L::Target: Logger {
2682
2678
// there are announced channels between the endpoints. If so, the hop might be
2683
2679
// referring to any of the announced channels, as its `short_channel_id` might be
2684
2680
// an alias, in which case we don't take any chances here.
2685
- network_graph. node ( & hop. node_id ) . map_or ( false , |hop_node|
2681
+ network_graph. node ( & hop. candidate . target ( ) ) . map_or ( false , |hop_node|
2686
2682
hop_node. channels . iter ( ) . any ( |scid| network_graph. channel ( * scid)
2687
2683
. map_or ( false , |c| c. as_directed_from ( & prev_hop_node_id) . is_some ( ) ) )
2688
2684
)
2689
2685
} ;
2690
2686
2691
2687
hops. push ( RouteHop {
2692
- pubkey : PublicKey :: from_slice ( hop. node_id . as_slice ( ) ) . map_err ( |_| LightningError { err : format ! ( "Public key {:?} is invalid" , & hop. node_id ) , action : ErrorAction :: IgnoreAndLog ( Level :: Trace ) } ) ?,
2688
+ pubkey : PublicKey :: from_slice ( hop. candidate . target ( ) . as_slice ( ) ) . map_err ( |_| LightningError { err : format ! ( "Public key {:?} is invalid" , & hop. candidate . target ( ) ) , action : ErrorAction :: IgnoreAndLog ( Level :: Trace ) } ) ?,
2693
2689
node_features : node_features. clone ( ) ,
2694
2690
short_channel_id : hop. candidate . short_channel_id ( ) . unwrap ( ) ,
2695
2691
channel_features : hop. candidate . features ( ) ,
@@ -2698,7 +2694,7 @@ where L::Target: Logger {
2698
2694
maybe_announced_channel,
2699
2695
} ) ;
2700
2696
2701
- prev_hop_node_id = hop. node_id ;
2697
+ prev_hop_node_id = hop. candidate . target ( ) ;
2702
2698
}
2703
2699
let mut final_cltv_delta = final_cltv_expiry_delta;
2704
2700
let blinded_tail = payment_path. hops . last ( ) . and_then ( |( h, _) | {
0 commit comments