use ln::features::{ChannelFeatures, InvoiceFeatures, NodeFeatures};
use ln::msgs::{DecodeError, ErrorAction, LightningError, MAX_VALUE_MSAT};
use routing::scoring::Score;
-use routing::network_graph::{DirectedChannelInfo, EffectiveCapacity, NetworkGraph, NodeId, RoutingFees};
+use routing::network_graph::{DirectedChannelInfoWithUpdate, EffectiveCapacity, NetworkGraph, NodeId, RoutingFees};
use util::ser::{Writeable, Readable};
use util::logger::{Level, Logger};
},
/// A hop found in the [`NetworkGraph`], where the channel capacity may or may not be known.
PublicHop {
- // `DirectedChannelInfo::direction` MUST NOT be `None`.
- info: DirectedChannelInfo<'a, 'a>,
+ info: DirectedChannelInfoWithUpdate<'a>,
short_channel_id: u64,
},
/// A hop to the payee found in the payment invoice, though not necessarily a direct channel.
}
}
+ // NOTE: This may copy bytes to so avoid calling it in a hot code path.
fn features(&self) -> ChannelFeatures {
match self {
CandidateRouteHop::FirstHop { details } => details.counterparty.features.to_context(),
fn cltv_expiry_delta(&self) -> u32 {
match self {
CandidateRouteHop::FirstHop { .. } => 0,
- CandidateRouteHop::PublicHop { info, .. } => {
- info.direction().unwrap().cltv_expiry_delta as u32
- },
+ CandidateRouteHop::PublicHop { info, .. } => info.direction().cltv_expiry_delta as u32,
CandidateRouteHop::PrivateHop { hint } => hint.cltv_expiry_delta as u32,
}
}
fn htlc_minimum_msat(&self) -> u64 {
match self {
CandidateRouteHop::FirstHop { .. } => 0,
- CandidateRouteHop::PublicHop { info, .. } => {
- info.direction().unwrap().htlc_minimum_msat
- },
+ CandidateRouteHop::PublicHop { info, .. } => info.direction().htlc_minimum_msat,
CandidateRouteHop::PrivateHop { hint } => hint.htlc_minimum_msat.unwrap_or(0),
}
}
CandidateRouteHop::FirstHop { .. } => RoutingFees {
base_msat: 0, proportional_millionths: 0,
},
- CandidateRouteHop::PublicHop { info, .. } => info.direction().unwrap().fees,
+ CandidateRouteHop::PublicHop { info, .. } => info.direction().fees,
CandidateRouteHop::PrivateHop { hint } => hint.fees,
}
}
for chan_id in $node.channels.iter() {
let chan = network_channels.get(chan_id).unwrap();
if !chan.features.requires_unknown_bits() {
- let directed_channel =
+ let (directed_channel, source) =
chan.as_directed_to(&$node_id).expect("inconsistent NetworkGraph");
- let source = directed_channel.source();
- let target = directed_channel.target();
if first_hops.is_none() || *source != our_node_id {
if let Some(direction) = directed_channel.direction() {
if direction.enabled {
let candidate = CandidateRouteHop::PublicHop {
- info: directed_channel,
+ info: directed_channel.with_update().unwrap(),
short_channel_id: *chan_id,
};
- add_entry!(candidate, *source, *target, $fee_to_target_msat, $next_hops_value_contribution, $next_hops_path_htlc_minimum_msat, $next_hops_path_penalty_msat, $next_hops_cltv_delta);
+ add_entry!(candidate, *source, $node_id, $fee_to_target_msat, $next_hops_value_contribution, $next_hops_path_htlc_minimum_msat, $next_hops_path_penalty_msat, $next_hops_cltv_delta);
}
}
}
let candidate = network_channels
.get(&hop.short_channel_id)
.and_then(|channel| channel.as_directed_to(&target))
- .and_then(|channel| channel.direction().map(|_| channel))
+ .and_then(|(channel, _)| channel.with_update())
.map(|info| CandidateRouteHop::PublicHop {
info,
short_channel_id: hop.short_channel_id,