- let mut path = payment_path.hops.iter().filter(|(h, _)| h.candidate.short_channel_id().is_some())
- .map(|(payment_hop, node_features)| {
- Ok(RouteHop {
- pubkey: PublicKey::from_slice(payment_hop.node_id.as_slice()).map_err(|_| LightningError{err: format!("Public key {:?} is invalid", &payment_hop.node_id), action: ErrorAction::IgnoreAndLog(Level::Trace)})?,
- node_features: node_features.clone(),
- short_channel_id: payment_hop.candidate.short_channel_id().unwrap(),
- channel_features: payment_hop.candidate.features(),
- fee_msat: payment_hop.fee_msat,
- cltv_expiry_delta: payment_hop.candidate.cltv_expiry_delta(),
- })
- }).collect::<Vec<_>>();
+ let mut hops = Vec::with_capacity(payment_path.hops.len());
+ for (hop, node_features) in payment_path.hops.iter()
+ .filter(|(h, _)| h.candidate.short_channel_id().is_some())
+ {
+ hops.push(RouteHop {
+ pubkey: PublicKey::from_slice(hop.node_id.as_slice()).map_err(|_| LightningError{err: format!("Public key {:?} is invalid", &hop.node_id), action: ErrorAction::IgnoreAndLog(Level::Trace)})?,
+ node_features: node_features.clone(),
+ short_channel_id: hop.candidate.short_channel_id().unwrap(),
+ channel_features: hop.candidate.features(),
+ fee_msat: hop.fee_msat,
+ cltv_expiry_delta: hop.candidate.cltv_expiry_delta(),
+ });
+ }