@@ -168,7 +168,7 @@ struct DummyDirectionalChannelInfo {
168
168
/// so that we can choose cheaper paths (as per Dijkstra's algorithm).
169
169
/// Fee values should be updated only in the context of the whole path, see update_value_and_recompute_fees.
170
170
/// These fee values are useful to choose hops as we traverse the graph "payee-to-payer".
171
- #[ derive( Clone ) ]
171
+ #[ derive( Clone , Debug ) ]
172
172
struct PathBuildingHop < ' a > {
173
173
// The RouteHintHop fields which will eventually be used if this hop is used in a final Route.
174
174
// Note that node_features is calculated separately after our initial graph walk.
@@ -506,6 +506,8 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
506
506
// - when we want to stop looking for new paths.
507
507
let mut already_collected_value_msat = 0 ;
508
508
509
+ log_trace ! ( logger, "Building path from {} (payee) to {} (us/payer) for value {} msat." , payee, our_node_id, final_value_msat) ;
510
+
509
511
macro_rules! add_entry {
510
512
// Adds entry which goes from $src_node_id to $dest_node_id
511
513
// over the channel with id $chan_id with fees described in
@@ -891,6 +893,8 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
891
893
}
892
894
}
893
895
896
+ log_trace ! ( logger, "Starting main path collection loop with {} nodes pre-filled from first/last hops." , targets. len( ) ) ;
897
+
894
898
// At this point, targets are filled with the data from first and
895
899
// last hops communicated by the caller, and the payment receiver.
896
900
let mut found_new_path = false ;
@@ -954,6 +958,9 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
954
958
ordered_hops. last_mut ( ) . unwrap ( ) . 0 . hop_use_fee_msat = 0 ;
955
959
ordered_hops. last_mut ( ) . unwrap ( ) . 0 . cltv_expiry_delta = final_cltv;
956
960
961
+ log_trace ! ( logger, "Found a path back to us from the target with {} hops contributing up to {} msat: {:?}" ,
962
+ ordered_hops. len( ) , value_contribution_msat, ordered_hops) ;
963
+
957
964
let mut payment_path = PaymentPath { hops : ordered_hops} ;
958
965
959
966
// We could have possibly constructed a slightly inconsistent path: since we reduce
@@ -989,8 +996,9 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
989
996
// If we weren't capped by hitting a liquidity limit on a channel in the path,
990
997
// we'll probably end up picking the same path again on the next iteration.
991
998
// Decrease the available liquidity of a hop in the middle of the path.
992
- let victim_liquidity = bookkeeped_channels_liquidity_available_msat. get_mut (
993
- & payment_path. hops [ ( payment_path. hops . len ( ) - 1 ) / 2 ] . 0 . short_channel_id ) . unwrap ( ) ;
999
+ let victim_scid = payment_path. hops [ ( payment_path. hops . len ( ) - 1 ) / 2 ] . 0 . short_channel_id ;
1000
+ log_trace ! ( logger, "Disabling channel {} for future path building iterations to avoid duplicates." , victim_scid) ;
1001
+ let victim_liquidity = bookkeeped_channels_liquidity_available_msat. get_mut ( & victim_scid) . unwrap ( ) ;
994
1002
* victim_liquidity = 0 ;
995
1003
}
996
1004
@@ -1032,6 +1040,8 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
1032
1040
// In the latter case, making another path finding attempt won't help,
1033
1041
// because we deterministically terminated the search due to low liquidity.
1034
1042
if already_collected_value_msat >= recommended_value_msat || !found_new_path {
1043
+ log_trace ! ( logger, "Have now collected {} (seeking {}) in paths. Last path loop {} a new path." ,
1044
+ already_collected_value_msat, recommended_value_msat, if found_new_path { "found" } else { "did not find" } ) ;
1035
1045
break ' paths_collection;
1036
1046
} else if found_new_path && already_collected_value_msat == final_value_msat && payment_paths. len ( ) == 1 {
1037
1047
// Further, if this was our first walk of the graph, and we weren't limited by an
@@ -1040,8 +1050,10 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
1040
1050
// potentially allowing us to pay fees to meet the htlc_minimum on the new path while
1041
1051
// still keeping a lower total fee than this path.
1042
1052
if !hit_minimum_limit {
1053
+ log_trace ! ( logger, "Collected exactly our payment amount on the first pass, without hitting an htlc_minimum_msat limit, exiting." ) ;
1043
1054
break ' paths_collection;
1044
1055
}
1056
+ log_trace ! ( logger, "Collected our payment amount on the first pass, but running again to collect extra paths with a potentially higher limit." ) ;
1045
1057
path_value_msat = recommended_value_msat;
1046
1058
}
1047
1059
}
@@ -1152,7 +1164,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
1152
1164
}
1153
1165
1154
1166
let route = Route { paths : selected_paths } ;
1155
- log_trace ! ( logger, "Got route: {}" , log_route!( route) ) ;
1167
+ log_info ! ( logger, "Got route to {} : {}" , payee , log_route!( route) ) ;
1156
1168
Ok ( route)
1157
1169
}
1158
1170
0 commit comments