Skip to content

Commit 57857fd

Browse files
committed
#[inline] CandidateRouteHop accessors
These are used in the performance-critical routing and scoring operations, which may happen outside of our crate. Thus, we really need to allow downstream crates to inline these accessors into their code, which we do here.
1 parent fc44e84 commit 57857fd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lightning/src/routing/router.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,7 @@ impl<'a> CandidateRouteHop<'a> {
11001100
///
11011101
/// Note that this is deliberately not public as it is somewhat of a footgun because it doesn't
11021102
/// define a global namespace.
1103+
#[inline]
11031104
fn short_channel_id(&self) -> Option<u64> {
11041105
match self {
11051106
CandidateRouteHop::FirstHop { details, .. } => details.get_outbound_payment_scid(),
@@ -1115,6 +1116,7 @@ impl<'a> CandidateRouteHop<'a> {
11151116
/// This only returns `Some` if the channel is public (either our own, or one we've learned
11161117
/// from the public network graph), and thus the short channel ID we have for this channel is
11171118
/// globally unique and identifies this channel in a global namespace.
1119+
#[inline]
11181120
pub fn globally_unique_short_channel_id(&self) -> Option<u64> {
11191121
match self {
11201122
CandidateRouteHop::FirstHop { details, .. } => if details.is_public { details.short_channel_id } else { None },
@@ -1137,6 +1139,7 @@ impl<'a> CandidateRouteHop<'a> {
11371139
}
11381140

11391141
/// Returns cltv_expiry_delta for this hop.
1142+
#[inline]
11401143
pub fn cltv_expiry_delta(&self) -> u32 {
11411144
match self {
11421145
CandidateRouteHop::FirstHop { .. } => 0,
@@ -1148,6 +1151,7 @@ impl<'a> CandidateRouteHop<'a> {
11481151
}
11491152

11501153
/// Returns the htlc_minimum_msat for this hop.
1154+
#[inline]
11511155
pub fn htlc_minimum_msat(&self) -> u64 {
11521156
match self {
11531157
CandidateRouteHop::FirstHop { details, .. } => details.next_outbound_htlc_minimum_msat,
@@ -1159,6 +1163,7 @@ impl<'a> CandidateRouteHop<'a> {
11591163
}
11601164

11611165
/// Returns the fees for this hop.
1166+
#[inline]
11621167
pub fn fees(&self) -> RoutingFees {
11631168
match self {
11641169
CandidateRouteHop::FirstHop { .. } => RoutingFees {
@@ -1196,6 +1201,7 @@ impl<'a> CandidateRouteHop<'a> {
11961201
/// Returns an ID describing the given hop.
11971202
///
11981203
/// See the docs on [`CandidateHopId`] for when this is, or is not, unique.
1204+
#[inline]
11991205
fn id(&self) -> CandidateHopId {
12001206
match self {
12011207
CandidateRouteHop::Blinded { hint_idx, .. } => CandidateHopId::Blinded(*hint_idx),
@@ -1216,6 +1222,7 @@ impl<'a> CandidateRouteHop<'a> {
12161222
/// Source node id refers to the hop forwarding the payment.
12171223
///
12181224
/// For `FirstHop` we return payer's node id.
1225+
#[inline]
12191226
pub fn source(&self) -> NodeId {
12201227
match self {
12211228
CandidateRouteHop::FirstHop { node_id, .. } => *node_id,
@@ -1230,7 +1237,8 @@ impl<'a> CandidateRouteHop<'a> {
12301237
/// Target node id refers to the hop receiving the payment.
12311238
///
12321239
/// For `Blinded` and `OneHopBlinded` we return `None` because next hop is blinded.
1233-
pub fn target(&self) -> Option<NodeId> {
1240+
#[inline]
1241+
pub fn target(&self) -> Option<NodeId> {
12341242
match self {
12351243
CandidateRouteHop::FirstHop { details, .. } => Some(details.counterparty.node_id.into()),
12361244
CandidateRouteHop::PublicHop { info, .. } => Some(*info.target()),

0 commit comments

Comments
 (0)