Skip to content

Commit 8330453

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 8ee1165 commit 8330453

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
@@ -2168,20 +2168,6 @@ where L::Target: Logger {
21682168
}
21692169
}
21702170

2171-
let mut private_hop_key_cache = hash_map_with_capacity(
2172-
payment_params.payee.unblinded_route_hints().iter().map(|path| path.0.len()).sum()
2173-
);
2174-
2175-
// Because we store references to private hop node_ids in `dist`, below, we need them to exist
2176-
// (as `NodeId`, not `PublicKey`) for the lifetime of `dist`. Thus, we calculate all the keys
2177-
// we'll need here and simply fetch them when routing.
2178-
private_hop_key_cache.insert(maybe_dummy_payee_pk, NodeId::from_pubkey(&maybe_dummy_payee_pk));
2179-
for route in payment_params.payee.unblinded_route_hints().iter() {
2180-
for hop in route.0.iter() {
2181-
private_hop_key_cache.insert(hop.src_node_id, NodeId::from_pubkey(&hop.src_node_id));
2182-
}
2183-
}
2184-
21852171
let node_counters = node_counters.build();
21862172

21872173
// The main heap containing all candidate next-hops sorted by their score (max(fee,
@@ -2770,7 +2756,9 @@ where L::Target: Logger {
27702756
let mut aggregate_path_contribution_msat = path_value_msat;
27712757

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

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

0 commit comments

Comments
 (0)