+ let mut private_hop_key_cache = HashMap::with_capacity(
+ payment_params.payee.unblinded_route_hints().iter().map(|path| path.0.len()).sum()
+ );
+
+ // Because we store references to private hop node_ids in `dist`, below, we need them to exist
+ // (as `NodeId`, not `PublicKey`) for the lifetime of `dist`. Thus, we calculate all the keys
+ // we'll need here and simply fetch them when routing.
+ private_hop_key_cache.insert(maybe_dummy_payee_pk, NodeId::from_pubkey(&maybe_dummy_payee_pk));
+ for route in payment_params.payee.unblinded_route_hints().iter() {
+ for hop in route.0.iter() {
+ private_hop_key_cache.insert(hop.src_node_id, NodeId::from_pubkey(&hop.src_node_id));
+ }
+ }
+