Skip to content

Commit 5f5bc41

Browse files
committed
[router] Add and clarify comments describing router internals
1 parent bb62420 commit 5f5bc41

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

lightning/src/routing/router.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,12 @@ impl<'a> PaymentPath<'a> {
249249
// If the amount transferred by the path is updated, the fees should be adjusted. Any other way
250250
// to change fees may result in an inconsistency.
251251
//
252-
// Sometimes we call this function right after constructing a path which has inconsistent
253-
// (in terms of reaching htlc_minimum_msat), so that this function puts the fees in order.
254-
// In that case we call it on the "same" amount we initially allocated for this path, and which
255-
// could have been reduced on the way. In that case, there is also a risk of exceeding
256-
// available_liquidity inside this function, because the function is unaware of this bound.
257-
// In our specific recomputation cases where we never increase the value the risk is pretty low.
258-
// This function, however, does not support arbitrarily increasing the value being transferred,
259-
// and the exception will be triggered.
252+
// Sometimes we call this function right after constructing a path which is inconsistent in
253+
// that it the value being transferred has decreased while we were doing path finding, leading
254+
// to the fees being paid not lining up with the actual limits.
255+
//
256+
// Note that this function is not aware of the available_liquidity limit, and thus does not
257+
// support increasing the value being transferred.
260258
fn update_value_and_recompute_fees(&mut self, value_msat: u64) {
261259
assert!(value_msat <= self.hops.last().unwrap().0.fee_msat);
262260

@@ -478,7 +476,13 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
478476

479477
let empty_channel_features = ChannelFeatures::empty();
480478

481-
let mut targets = BinaryHeap::new(); //TODO: Do we care about switching to eg Fibbonaci heap?
479+
// The main heap containing all candidate next-hops sorted by their score (max(A* fee,
480+
// htlc_minimum)). Ideally this would be a heap which allowed cheap score reduction instead of
481+
// adding duplicate entries when we find a better path to a given node.
482+
let mut targets = BinaryHeap::new();
483+
484+
// Map from node_id to information about the best current path to that node, including feerate
485+
// information.
482486
let mut dist = HashMap::with_capacity(network.get_nodes().len());
483487

484488
// During routing, if we ignore a path due to an htlc_minimum_msat limit, we set this,

0 commit comments

Comments
 (0)