@@ -1196,6 +1196,7 @@ impl_writeable_tlv_based!(RouteHintHop, {
1196
1196
#[ repr( align( 64 ) ) ] // Force the size to 64 bytes
1197
1197
struct RouteGraphNode {
1198
1198
node_id : NodeId ,
1199
+ node_counter : u32 ,
1199
1200
score : u64 ,
1200
1201
// The maximum value a yet-to-be-constructed payment path might flow through this node.
1201
1202
// This value is upper-bounded by us by:
@@ -1210,7 +1211,7 @@ struct RouteGraphNode {
1210
1211
1211
1212
impl cmp:: Ord for RouteGraphNode {
1212
1213
fn cmp ( & self , other : & RouteGraphNode ) -> cmp:: Ordering {
1213
- other. score . cmp ( & self . score ) . then_with ( || other. node_id . cmp ( & self . node_id ) )
1214
+ other. score . cmp ( & self . score ) . then_with ( || other. node_counter . cmp ( & self . node_counter ) )
1214
1215
}
1215
1216
}
1216
1217
@@ -2657,6 +2658,7 @@ where L::Target: Logger {
2657
2658
if !old_entry. was_processed && new_cost < old_cost {
2658
2659
let new_graph_node = RouteGraphNode {
2659
2660
node_id: src_node_id,
2661
+ node_counter: src_node_counter,
2660
2662
score: cmp:: max( total_fee_msat, path_htlc_minimum_msat) . saturating_add( path_penalty_msat) ,
2661
2663
total_cltv_delta: hop_total_cltv_delta,
2662
2664
value_contribution_msat,
@@ -2735,7 +2737,7 @@ where L::Target: Logger {
2735
2737
// meaning how much will be paid in fees after this node (to the best of our knowledge).
2736
2738
// This data can later be helpful to optimize routing (pay lower fees).
2737
2739
macro_rules! add_entries_to_cheapest_to_target_node {
2738
- ( $node: expr, $node_id: expr, $next_hops_value_contribution: expr,
2740
+ ( $node: expr, $node_counter : expr , $ node_id: expr, $next_hops_value_contribution: expr,
2739
2741
$next_hops_cltv_delta: expr, $next_hops_path_length: expr ) => {
2740
2742
let fee_to_target_msat;
2741
2743
let next_hops_path_htlc_minimum_msat;
@@ -2875,7 +2877,9 @@ where L::Target: Logger {
2875
2877
// If not, targets.pop() will not even let us enter the loop in step 2.
2876
2878
None => { } ,
2877
2879
Some ( node) => {
2878
- add_entries_to_cheapest_to_target_node ! ( node, payee, path_value_msat, 0 , 0 ) ;
2880
+ add_entries_to_cheapest_to_target_node ! (
2881
+ node, node. node_counter, payee, path_value_msat, 0 , 0
2882
+ ) ;
2879
2883
} ,
2880
2884
} ) ;
2881
2885
@@ -3103,7 +3107,7 @@ where L::Target: Logger {
3103
3107
// Both these cases (and other cases except reaching recommended_value_msat) mean that
3104
3108
// paths_collection will be stopped because found_new_path==false.
3105
3109
// This is not necessarily a routing failure.
3106
- ' path_construction: while let Some ( RouteGraphNode { node_id, total_cltv_delta, mut value_contribution_msat, path_length_to_node, .. } ) = targets. pop ( ) {
3110
+ ' path_construction: while let Some ( RouteGraphNode { node_id, node_counter , total_cltv_delta, mut value_contribution_msat, path_length_to_node, .. } ) = targets. pop ( ) {
3107
3111
3108
3112
// Since we're going payee-to-payer, hitting our node as a target means we should stop
3109
3113
// traversing the graph and arrange the path out of what we found.
@@ -3241,7 +3245,8 @@ where L::Target: Logger {
3241
3245
match network_nodes. get ( & node_id) {
3242
3246
None => { } ,
3243
3247
Some ( node) => {
3244
- add_entries_to_cheapest_to_target_node ! ( node, node_id,
3248
+ add_entries_to_cheapest_to_target_node ! (
3249
+ node, node_counter, node_id,
3245
3250
value_contribution_msat,
3246
3251
total_cltv_delta, path_length_to_node) ;
3247
3252
} ,
0 commit comments