@@ -1164,6 +1164,7 @@ impl_writeable_tlv_based!(RouteHintHop, {
11641164#[ repr( align( 64 ) ) ] // Force the size to 64 bytes
11651165struct RouteGraphNode {
11661166 node_id : NodeId ,
1167+ node_counter : u32 ,
11671168 score : u64 ,
11681169 // The maximum value a yet-to-be-constructed payment path might flow through this node.
11691170 // This value is upper-bounded by us by:
@@ -1178,7 +1179,7 @@ struct RouteGraphNode {
11781179
11791180impl cmp:: Ord for RouteGraphNode {
11801181 fn cmp ( & self , other : & RouteGraphNode ) -> cmp:: Ordering {
1181- other. score . cmp ( & self . score ) . then_with ( || other. node_id . cmp ( & self . node_id ) )
1182+ other. score . cmp ( & self . score ) . then_with ( || other. node_counter . cmp ( & self . node_counter ) )
11821183 }
11831184}
11841185
@@ -2625,6 +2626,7 @@ where L::Target: Logger {
26252626 if !old_entry. was_processed && new_cost < old_cost {
26262627 let new_graph_node = RouteGraphNode {
26272628 node_id: src_node_id,
2629+ node_counter: src_node_counter,
26282630 score: cmp:: max( total_fee_msat, path_htlc_minimum_msat) . saturating_add( path_penalty_msat) ,
26292631 total_cltv_delta: hop_total_cltv_delta,
26302632 value_contribution_msat,
@@ -2703,7 +2705,7 @@ where L::Target: Logger {
27032705 // meaning how much will be paid in fees after this node (to the best of our knowledge).
27042706 // This data can later be helpful to optimize routing (pay lower fees).
27052707 macro_rules! add_entries_to_cheapest_to_target_node {
2706- ( $node: expr, $node_id: expr, $next_hops_value_contribution: expr,
2708+ ( $node: expr, $node_counter : expr , $ node_id: expr, $next_hops_value_contribution: expr,
27072709 $next_hops_cltv_delta: expr, $next_hops_path_length: expr ) => {
27082710 let fee_to_target_msat;
27092711 let next_hops_path_htlc_minimum_msat;
@@ -2843,7 +2845,9 @@ where L::Target: Logger {
28432845 // If not, targets.pop() will not even let us enter the loop in step 2.
28442846 None => { } ,
28452847 Some ( node) => {
2846- add_entries_to_cheapest_to_target_node ! ( node, payee, path_value_msat, 0 , 0 ) ;
2848+ add_entries_to_cheapest_to_target_node ! (
2849+ node, node. node_counter, payee, path_value_msat, 0 , 0
2850+ ) ;
28472851 } ,
28482852 } ) ;
28492853
@@ -3071,7 +3075,7 @@ where L::Target: Logger {
30713075 // Both these cases (and other cases except reaching recommended_value_msat) mean that
30723076 // paths_collection will be stopped because found_new_path==false.
30733077 // This is not necessarily a routing failure.
3074- ' path_construction: while let Some ( RouteGraphNode { node_id, total_cltv_delta, mut value_contribution_msat, path_length_to_node, .. } ) = targets. pop ( ) {
3078+ ' path_construction: while let Some ( RouteGraphNode { node_id, node_counter , total_cltv_delta, mut value_contribution_msat, path_length_to_node, .. } ) = targets. pop ( ) {
30753079
30763080 // Since we're going payee-to-payer, hitting our node as a target means we should stop
30773081 // traversing the graph and arrange the path out of what we found.
@@ -3209,7 +3213,8 @@ where L::Target: Logger {
32093213 match network_nodes. get ( & node_id) {
32103214 None => { } ,
32113215 Some ( node) => {
3212- add_entries_to_cheapest_to_target_node ! ( node, node_id,
3216+ add_entries_to_cheapest_to_target_node ! (
3217+ node, node_counter, node_id,
32133218 value_contribution_msat,
32143219 total_cltv_delta, path_length_to_node) ;
32153220 } ,
0 commit comments