Skip to content

Commit bc4402d

Browse files
committed
Drop private_hop_key_cache in favor of NodeCounters
With the new `NodeCounters` have have a all the `NodeId`s we'll need during routing, so there's no need to keep the `private_hop_key_cache` which existed to provide references to `NodeId`s which are needed during routing.
1 parent 8249aa1 commit bc4402d

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

lightning/src/routing/router.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,20 +2155,6 @@ where L::Target: Logger {
21552155
}
21562156
}
21572157

2158-
let mut private_hop_key_cache = hash_map_with_capacity(
2159-
payment_params.payee.unblinded_route_hints().iter().map(|path| path.0.len()).sum()
2160-
);
2161-
2162-
// Because we store references to private hop node_ids in `dist`, below, we need them to exist
2163-
// (as `NodeId`, not `PublicKey`) for the lifetime of `dist`. Thus, we calculate all the keys
2164-
// we'll need here and simply fetch them when routing.
2165-
private_hop_key_cache.insert(maybe_dummy_payee_pk, NodeId::from_pubkey(&maybe_dummy_payee_pk));
2166-
for route in payment_params.payee.unblinded_route_hints().iter() {
2167-
for hop in route.0.iter() {
2168-
private_hop_key_cache.insert(hop.src_node_id, NodeId::from_pubkey(&hop.src_node_id));
2169-
}
2170-
}
2171-
21722158
let node_counters = node_counters.build();
21732159

21742160
// The main heap containing all candidate next-hops sorted by their score (max(fee,
@@ -2757,7 +2743,9 @@ where L::Target: Logger {
27572743
let mut aggregate_path_contribution_msat = path_value_msat;
27582744

27592745
for (idx, (hop, prev_hop_id)) in hop_iter.zip(prev_hop_iter).enumerate() {
2760-
let target = private_hop_key_cache.get(prev_hop_id).unwrap();
2746+
let (target, _private_target_node_counter) =
2747+
node_counters.private_node_counter_from_pubkey(&prev_hop_id)
2748+
.expect("node_counter_from_pubkey is called on all unblinded_route_hints keys during setup, so is always Some here");
27612749

27622750
if let Some(first_channels) = first_hop_targets.get(target) {
27632751
if first_channels.iter().any(|d| d.outbound_scid_alias == Some(hop.short_channel_id)) {

0 commit comments

Comments
 (0)