Skip to content

Commit 6edb4fe

Browse files
committed
Correct step number in get_route
1 parent ad819ea commit 6edb4fe

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lightning/src/routing/router.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
897897
},
898898
}
899899

900-
// Step (1).
900+
// Step (2).
901901
// If a caller provided us with last hops, add them to routing targets. Since this happens
902902
// earlier than general path finding, they will be somewhat prioritized, although currently
903903
// it matters only if the fees are exactly the same.
@@ -995,7 +995,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
995995
// last hops communicated by the caller, and the payment receiver.
996996
let mut found_new_path = false;
997997

998-
// Step (2).
998+
// Step (3).
999999
// If this loop terminates due the exhaustion of targets, two situations are possible:
10001000
// - not enough outgoing liquidity:
10011001
// 0 < already_collected_value_msat < final_value_msat
@@ -1130,7 +1130,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
11301130
break 'paths_collection;
11311131
}
11321132

1133-
// Step (3).
1133+
// Step (4).
11341134
// Stop either when the recommended value is reached or if no new path was found in this
11351135
// iteration.
11361136
// In the latter case, making another path finding attempt won't help,
@@ -1154,7 +1154,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
11541154
}
11551155
}
11561156

1157-
// Step (4).
1157+
// Step (5).
11581158
if payment_paths.len() == 0 {
11591159
return Err(LightningError{err: "Failed to find a path to the given destination".to_owned(), action: ErrorAction::IgnoreError});
11601160
}
@@ -1175,12 +1175,12 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
11751175
let mut cur_route = Vec::<PaymentPath>::new();
11761176
let mut aggregate_route_value_msat = 0;
11771177

1178-
// Step (5).
1178+
// Step (6).
11791179
// TODO: real random shuffle
11801180
// Currently just starts with i_th and goes up to i-1_th in a looped way.
11811181
let cur_payment_paths = [&payment_paths[i..], &payment_paths[..i]].concat();
11821182

1183-
// Step (6).
1183+
// Step (7).
11841184
for payment_path in cur_payment_paths {
11851185
cur_route.push(payment_path.clone());
11861186
aggregate_route_value_msat += payment_path.get_value_msat();
@@ -1219,7 +1219,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
12191219

12201220
assert!(cur_route.len() > 0);
12211221

1222-
// Step (7).
1222+
// Step (8).
12231223
// Now, substract the overpaid value from the most-expensive path.
12241224
// TODO: this could also be optimized by also sorting by feerate_per_sat_routed,
12251225
// so that the sender pays less fees overall. And also htlc_minimum_msat.
@@ -1236,7 +1236,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
12361236
drawn_routes.push(cur_route);
12371237
}
12381238

1239-
// Step (8).
1239+
// Step (9).
12401240
// Select the best route by lowest total fee.
12411241
drawn_routes.sort_by_key(|paths| paths.iter().map(|path| path.get_total_fee_paid_msat()).sum::<u64>());
12421242
let mut selected_paths = Vec::<Vec<RouteHop>>::new();

0 commit comments

Comments
 (0)