Skip to content

Commit 52033e4

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 d1c962e commit 52033e4

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
@@ -1099,6 +1099,7 @@ impl<'a> CandidateRouteHop<'a> {
10991099
///
11001100
/// Note that this is deliberately not public as it is somewhat of a footgun because it doesn't
11011101
/// define a global namespace.
1102+
#[inline]
11021103
fn short_channel_id(&self) -> Option<u64> {
11031104
match self {
11041105
CandidateRouteHop::FirstHop { details, .. } => details.get_outbound_payment_scid(),
@@ -1114,6 +1115,7 @@ impl<'a> CandidateRouteHop<'a> {
11141115
/// This only returns `Some` if the channel is public (either our own, or one we've learned
11151116
/// from the public network graph), and thus the short channel ID we have for this channel is
11161117
/// globally unique and identifies this channel in a global namespace.
1118+
#[inline]
11171119
pub fn globally_unique_short_channel_id(&self) -> Option<u64> {
11181120
match self {
11191121
CandidateRouteHop::FirstHop { details, .. } => if details.is_public { details.short_channel_id } else { None },
@@ -1136,6 +1138,7 @@ impl<'a> CandidateRouteHop<'a> {
11361138
}
11371139

11381140
/// Returns cltv_expiry_delta for this hop.
1141+
#[inline]
11391142
pub fn cltv_expiry_delta(&self) -> u32 {
11401143
match self {
11411144
CandidateRouteHop::FirstHop { .. } => 0,
@@ -1147,6 +1150,7 @@ impl<'a> CandidateRouteHop<'a> {
11471150
}
11481151

11491152
/// Returns the htlc_minimum_msat for this hop.
1153+
#[inline]
11501154
pub fn htlc_minimum_msat(&self) -> u64 {
11511155
match self {
11521156
CandidateRouteHop::FirstHop { details, .. } => details.next_outbound_htlc_minimum_msat,
@@ -1158,6 +1162,7 @@ impl<'a> CandidateRouteHop<'a> {
11581162
}
11591163

11601164
/// Returns the fees for this hop.
1165+
#[inline]
11611166
pub fn fees(&self) -> RoutingFees {
11621167
match self {
11631168
CandidateRouteHop::FirstHop { .. } => RoutingFees {
@@ -1195,6 +1200,7 @@ impl<'a> CandidateRouteHop<'a> {
11951200
/// Returns an ID describing the given hop.
11961201
///
11971202
/// See the docs on [`CandidateHopId`] for when this is, or is not, unique.
1203+
#[inline]
11981204
fn id(&self) -> CandidateHopId {
11991205
match self {
12001206
CandidateRouteHop::Blinded { hint_idx, .. } => CandidateHopId::Blinded(*hint_idx),
@@ -1215,6 +1221,7 @@ impl<'a> CandidateRouteHop<'a> {
12151221
/// Source node id refers to the hop forwarding the payment.
12161222
///
12171223
/// For `FirstHop` we return payer's node id.
1224+
#[inline]
12181225
pub fn source(&self) -> NodeId {
12191226
match self {
12201227
CandidateRouteHop::FirstHop { node_id, .. } => *node_id,
@@ -1229,7 +1236,8 @@ impl<'a> CandidateRouteHop<'a> {
12291236
/// Target node id refers to the hop receiving the payment.
12301237
///
12311238
/// For `Blinded` and `OneHopBlinded` we return `None` because next hop is blinded.
1232-
pub fn target(&self) -> Option<NodeId> {
1239+
#[inline]
1240+
pub fn target(&self) -> Option<NodeId> {
12331241
match self {
12341242
CandidateRouteHop::FirstHop { details, .. } => Some(details.counterparty.node_id.into()),
12351243
CandidateRouteHop::PublicHop { info, .. } => Some(*info.target()),

0 commit comments

Comments
 (0)