Skip to content

Commit 8f00ba5

Browse files
committed
Setting the constant MAX_CHANNEL_HINTS at the file level
1 parent 3e6b9ae commit 8f00ba5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lightning-invoice/src/utils.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ where
133133
)
134134
}
135135

136+
const MAX_CHANNEL_HINTS: usize = 3;
137+
136138
fn _create_phantom_invoice<ES: Deref, NS: Deref, L: Deref>(
137139
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, description: InvoiceDescription,
138140
invoice_expiry_delta_secs: u32, phantom_route_hints: Vec<PhantomRouteHints>, entropy_source: ES,
@@ -203,9 +205,8 @@ where
203205
invoice = invoice.amount_milli_satoshis(amt);
204206
}
205207

206-
const MAX_HINTS: usize = 3;
207208

208-
for route_hint in select_phantom_hints(amt_msat, phantom_route_hints, logger).take(MAX_HINTS) {
209+
for route_hint in select_phantom_hints(amt_msat, phantom_route_hints, logger).take(MAX_CHANNEL_HINTS) {
209210
invoice = invoice.private_route(route_hint);
210211
}
211212

@@ -641,7 +642,7 @@ where
641642
// look at the public channels instead.
642643
log_trace!(logger, "Not including channels in invoice route hints on account of public channel {}",
643644
log_bytes!(channel.channel_id));
644-
return vec![].into_iter().take(3).map(route_hint_from_channel);
645+
return vec![].into_iter().take(MAX_CHANNEL_HINTS).map(route_hint_from_channel);
645646
}
646647
}
647648

@@ -751,7 +752,7 @@ where
751752
b.inbound_capacity_msat.cmp(&a.inbound_capacity_msat)
752753
}});
753754

754-
eligible_channels.into_iter().take(3).map(route_hint_from_channel)
755+
eligible_channels.into_iter().take(MAX_CHANNEL_HINTS).map(route_hint_from_channel)
755756
}
756757

757758
/// prefer_current_channel chooses a channel to use for route hints between a currently selected and candidate

0 commit comments

Comments
 (0)