Merge PR 'Fix warnings on `nightly`' (#4864)
What changed, and why it matters
This commit is a routine cleanup that fixes Rust compiler warnings on the nightly toolchain. It replaces deprecated ways of writing maximum integer values (like `u64::max_value()` and `std::usize::MAX`) with the modern equivalents (`u64::MAX`, `usize::MAX`), adds a missing semicolon in a log statement, and updates related comments. These changes do not alter program behavior or fix any security issue.
No security action required. Treat as normal maintenance; ensure CI passes on nightly Rust.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch is a pure refactoring to address nightly Rust deprecation warnings. It mechanically substitutes std::<type>::MAX/core::<type>::MAX/std::u64::MAX with <type>::MAX, and max_value() method calls with MAX associated constants. One missing semicolon is added in lightning-background-processor/src/lib.rs. No logic, constants, or control flow change; the compiled output is expected to be identical.
Changed components
fuzz/src/chanmon_consistency.rslightning-background-processor/src/lib.rslightning-block-sync/src/convert.rslightning-invoice/src/lib.rslightning/src/blinded_path/payment.rslightning/src/chain/chaininterface.rslightning/src/chain/package.rslightning/src/ln/blinded_payment_tests.rslightning/src/ln/channel.rslightning/src/ln/channelmanager.rslightning/src/ln/functional_test_utils.rslightning/src/ln/max_payment_path_len_tests.rslightning/src/ln/msgs.rslightning/src/ln/onion_route_tests.rslightning/src/ln/outbound_payment.rslightning/src/ln/peer_channel_encryptor.rslightning/src/ln/peer_handler.rslightning/src/ln/wire.rslightning/src/offers/invoice.rslightning/src/offers/invoice_request.rslightning/src/offers/offer.rslightning/src/offers/refund.rslightning/src/offers/static_invoice.rslightning/src/routing/gossip.rslightning/src/routing/router.rslightning/src/routing/scoring.rslightning/src/routing/test_utils.rslightning/src/sign/mod.rslightning/src/sign/tx_builder.rslightning/src/util/config.rslightning/src/util/test_utils.rsInspect captured patch +149 / −153
### fuzz/src/chanmon_consistency.rs
@@ -3735,7 +3735,7 @@ impl<'a, Out: Output + MaybeSend + MaybeSync> Harness<'a, Out> {
fn process_all_events(&mut self) {
let mut last_pass_no_updates = false;
- for i in 0..std::usize::MAX {
+ for i in 0..usize::MAX {
if i == MAX_SETTLE_ITERATIONS {
panic!(
"It may take many iterations to settle the state, but it should not take forever"
### lightning-background-processor/src/lib.rs
@@ -1630,7 +1630,7 @@ impl BackgroundProcessor {
SCORER_PERSISTENCE_KEY,
scorer.encode(),
) {
- log_error!(logger, "Error: Failed to persist scorer, check your disk and permissions {}", e)
+ log_error!(logger, "Error: Failed to persist scorer, check your disk and permissions {}", e);
}
}
}
### lightning-block-sync/src/convert.rs
@@ -682,7 +682,7 @@ pub(crate) mod tests {
let block = genesis_block(Network::Bitcoin);
let response = JsonResponse(serde_json::json!({
"bestblockhash": block.block_hash().to_string(),
- "blocks": std::u64::MAX,
+ "blocks": u64::MAX,
}));
match TryInto::<(BlockHash, Option<u32>)>::try_into(response) {
Err(e) => {
### lightning-invoice/src/lib.rs
@@ -1573,7 +1573,7 @@ impl Bolt11Invoice {
pub fn would_expire(&self, at_time: Duration) -> bool {
self.duration_since_epoch()
.checked_add(self.expiry_time())
- .unwrap_or_else(|| Duration::new(u64::max_value(), 1_000_000_000 - 1))
+ .unwrap_or_else(|| Duration::new(u64::MAX, 1_000_000_000 - 1))
< at_time
}
### lightning/src/blinded_path/payment.rs
@@ -93,7 +93,7 @@ impl BlindedPaymentPath {
) -> Result<Self, ()> {
// This value is not considered in pathfinding for 1-hop blinded paths, because it's intended to
// be in relation to a specific channel.
- let htlc_maximum_msat = u64::max_value();
+ let htlc_maximum_msat = u64::MAX;
Self::new(
&[],
payee_node_id,
@@ -1167,7 +1167,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
- htlc_maximum_msat: u64::max_value(),
+ htlc_maximum_msat: u64::MAX,
},
PaymentForwardNode {
node_id: dummy_pk,
@@ -1185,7 +1185,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
- htlc_maximum_msat: u64::max_value(),
+ htlc_maximum_msat: u64::MAX,
},
];
let recv_tlvs = ReceiveTlvs {
@@ -1252,7 +1252,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
- htlc_maximum_msat: u64::max_value(),
+ htlc_maximum_msat: u64::MAX,
},
PaymentForwardNode {
node_id: dummy_pk,
@@ -1270,7 +1270,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
- htlc_maximum_msat: u64::max_value(),
+ htlc_maximum_msat: u64::MAX,
},
];
let recv_tlvs = ReceiveTlvs {
@@ -1314,7 +1314,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
- htlc_maximum_msat: u64::max_value(),
+ htlc_maximum_msat: u64::MAX,
},
PaymentForwardNode {
node_id: dummy_pk,
@@ -1332,7 +1332,7 @@ mod tests {
next_blinding_override: None,
features: BlindedHopFeatures::empty(),
},
- htlc_maximum_msat: u64::max_value(),
+ htlc_maximum_msat: u64::MAX,
},
];
let recv_tlvs = ReceiveTlvs {
### lightning/src/chain/chaininterface.rs
@@ -178,7 +178,7 @@ impl_ser_tlv_based_enum!(FundingPurpose,
// TODO: Define typed abstraction over feerates to handle their conversions.
pub(crate) fn compute_feerate_sat_per_1000_weight(fee_sat: u64, weight: u64) -> u32 {
- (fee_sat * 1000 / weight).try_into().unwrap_or(u32::max_value())
+ (fee_sat * 1000 / weight).try_into().unwrap_or(u32::MAX)
}
pub(crate) const fn fee_for_weight(feerate_sat_per_1000_weight: u32, weight: u64) -> u64 {
(feerate_sat_per_1000_weight as u64 * weight).div_ceil(1000)
### lightning/src/chain/package.rs
@@ -1543,7 +1543,7 @@ impl PackageTemplate {
) -> u32 {
let feerate_estimate = fee_estimator.bounded_sat_per_1000_weight(conf_target);
if self.feerate_previous != 0 {
- let previous_feerate = self.feerate_previous.try_into().unwrap_or(u32::max_value());
+ let previous_feerate = self.feerate_previous.try_into().unwrap_or(u32::MAX);
match feerate_strategy {
FeerateStrategy::RetryPrevious => previous_feerate,
FeerateStrategy::HighestOfPreviousOrNew => cmp::max(previous_feerate, feerate_estimate),
@@ -1555,7 +1555,7 @@ impl PackageTemplate {
// so we choose to bump our previous feerate by 25%, making sure we don't use a
// lower feerate or overpay by a large margin by limiting it to 5x the new fee
// estimate.
- let previous_feerate = self.feerate_previous.try_into().unwrap_or(u32::max_value());
+ let previous_feerate = self.feerate_previous.try_into().unwrap_or(u32::MAX);
let mut new_feerate = previous_feerate.saturating_add(previous_feerate / 4);
if new_feerate > feerate_estimate * 5 {
new_feerate = cmp::max(feerate_estimate * 5, previous_feerate);
### lightning/src/ln/blinded_payment_tests.rs
@@ -66,7 +66,7 @@ pub fn blinded_payment_path(
fee_base_msat: chan_upd.fee_base_msat,
},
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: intro_node_min_htlc_opt.take()
.unwrap_or_else(|| channel_upds[idx - 1].htlc_minimum_msat),
},
@@ -81,7 +81,7 @@ pub fn blinded_payment_path(
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat:
intro_node_min_htlc_opt.unwrap_or_else(|| channel_upds.last().unwrap().htlc_minimum_msat),
},
@@ -171,7 +171,7 @@ fn do_one_hop_blinded_path(success: bool) {
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext { payment_metadata: None }),
@@ -215,7 +215,7 @@ fn one_hop_blinded_path_with_dummy_hops() {
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {
@@ -297,7 +297,7 @@ fn mpp_to_one_hop_blinded_path() {
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: chan_upd_1_3.htlc_minimum_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext { payment_metadata: None }),
@@ -1528,7 +1528,7 @@ fn custom_tlvs_to_blinded_path() {
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext { payment_metadata: None }),
@@ -1582,7 +1582,7 @@ fn fails_receive_tlvs_authentication() {
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext { payment_metadata: None }),
@@ -1612,7 +1612,7 @@ fn fails_receive_tlvs_authentication() {
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext { payment_metadata: None }),
@@ -2219,7 +2219,7 @@ fn test_trampoline_forward_payload_encoded_as_receive() {
let payee_tlvs = blinded_path::payment::TrampolineForwardTlvs {
next_trampoline: alice_node_id,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: amt_msat,
},
features: BlindedHopFeatures::empty(),
@@ -2400,7 +2400,7 @@ fn do_test_trampoline_single_hop_receive(success: bool) {
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: amt_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext { payment_metadata: None }),
@@ -2702,7 +2702,7 @@ fn do_test_trampoline_relay(blinded: bool, test_case: TrampolineTestCase) {
ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: original_amt_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {
@@ -2912,7 +2912,7 @@ fn send_trampoline_mpp_payment<'a, 'b, 'c>(
tlvs: blinded_path::payment::TrampolineForwardTlvs {
next_trampoline,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: 1,
},
features: BlindedHopFeatures::empty(),
@@ -2924,12 +2924,12 @@ fn send_trampoline_mpp_payment<'a, 'b, 'c>(
next_blinding_override: None,
},
node_id: carol_node_id,
- htlc_maximum_msat: u64::max_value(),
+ htlc_maximum_msat: u64::MAX,
}];
let payee_tlvs = ReceiveTlvs {
payment_secret: PaymentSecret([0; 32]),
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: 1,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {
### lightning/src/ln/channel.rs
@@ -7998,7 +7998,7 @@ where
// on-chain ChannelsMonitors during block rescan. Ideally we'd figure out a way to drop
// these, but for now we just have to treat them as normal.
- let mut pending_idx = core::usize::MAX;
+ let mut pending_idx = usize::MAX;
let mut htlc_value_msat = 0;
for (idx, htlc) in self.context.pending_inbound_htlcs.iter().enumerate() {
if htlc.htlc_id == htlc_id_arg {
@@ -8035,7 +8035,7 @@ where
break;
}
}
- if pending_idx == core::usize::MAX {
+ if pending_idx == usize::MAX {
return UpdateFulfillFetch::DuplicateClaim {};
}
@@ -8229,7 +8229,7 @@ where
// on-chain ChannelsMonitors during block rescan. Ideally we'd figure out a way to drop
// these, but for now we just have to treat them as normal.
- let mut pending_idx = core::usize::MAX;
+ let mut pending_idx = usize::MAX;
for (idx, htlc) in self.context.pending_inbound_htlcs.iter().enumerate() {
if htlc.htlc_id == htlc_id_arg {
match htlc.state {
@@ -8245,7 +8245,7 @@ where
pending_idx = idx;
}
}
- if pending_idx == core::usize::MAX {
+ if pending_idx == usize::MAX {
return Err(ChannelError::Ignore(format!("Unable to find a pending HTLC which matched the given HTLC ID ({})", htlc_id_arg)));
}
@@ -11336,7 +11336,7 @@ where
let normal_feerate =
fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::NonAnchorChannelFee);
let mut proposed_max_feerate =
- if self.funding.is_outbound() { normal_feerate } else { u32::max_value() };
+ if self.funding.is_outbound() { normal_feerate } else { u32::MAX };
// The spec requires that (when the channel does not have anchors) we only send absolute
// channel fees no greater than the absolute channel fee on the current commitment
### lightning/src/ln/channelmanager.rs
@@ -6784,7 +6784,7 @@ impl<
}
}
- if funding_transaction.output.len() > u16::max_value() as usize {
+ if funding_transaction.output.len() > u16::MAX as usize {
result = result.and(Err(APIError::APIMisuseError {
err: "Transaction had more than 2^16 outputs, which is not supported"
.to_owned(),
### lightning/src/ln/functional_test_utils.rs
@@ -5875,7 +5875,7 @@ pub fn create_trampoline_forward_blinded_tail<ES: EntropySource>(
payee_node_id,
payee_receive_key,
payee_tlvs,
- u64::max_value(),
+ u64::MAX,
min_final_cltv_expiry_delta as u16,
entropy_source,
secp_ctx,
### lightning/src/ln/max_payment_path_len_tests.rs
@@ -252,7 +252,7 @@ fn one_hop_blinded_path_with_custom_tlv() {
let payee_tlvs = ReceiveTlvs {
payment_secret,
payment_constraints: PaymentConstraints {
- max_cltv_expiry: u32::max_value(),
+ max_cltv_expiry: u32::MAX,
htlc_minimum_msat: chan_upd_1_2.htlc_minimum_msat,
},
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {
### lightning/src/ln/msgs.rs
@@ -4478,10 +4478,7 @@ impl QueryChannelRange {
///
/// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
pub fn end_blocknum(&self) -> u32 {
- match self.first_blocknum.checked_add(self.number_of_blocks) {
- Some(block) => block,
- None => u32::max_value(),
- }
+ self.first_blocknum.checked_add(self.number_of_blocks).unwrap_or(u32::MAX)
}
}
### lightning/src/ln/onion_route_tests.rs
@@ -1736,7 +1736,7 @@ fn do_test_onion_failure_stale_channel_update(announce_for_forwarding: bool) {
.unwrap()
.config
.unwrap();
- config.forwarding_fee_base_msat = u32::max_value();
+ config.forwarding_fee_base_msat = u32::MAX;
let msg = update_and_get_channel_update(&config.clone(), true, None, false).unwrap();
// The old policy should still be in effect until a new block is connected.
@@ -1765,14 +1765,14 @@ fn do_test_onion_failure_stale_channel_update(announce_for_forwarding: bool) {
// Reset the base fee to the default and increase the proportional fee which should trigger a
// new ChannelUpdate.
config.forwarding_fee_base_msat = default_config.forwarding_fee_base_msat;
- config.cltv_expiry_delta = u16::max_value();
+ config.cltv_expiry_delta = u16::MAX;
assert!(update_and_get_channel_update(&config, true, Some(&msg), true).is_some());
expect_onion_failure("incorrect_cltv_expiry", LocalHTLCFailureReason::IncorrectCLTVExpiry);
// Reset the proportional fee and increase the CLTV expiry delta which should trigger a new
// ChannelUpdate.
config.cltv_expiry_delta = default_config.cltv_expiry_delta;
- config.forwarding_fee_proportional_millionths = u32::max_value();
+ config.forwarding_fee_proportional_millionths = u32::MAX;
assert!(update_and_get_channel_update(&config, true, Some(&msg), true).is_some());
expect_onion_failure("fee_insufficient", LocalHTLCFailureReason::FeeInsufficient);
### lightning/src/ln/outbound_payment.rs
@@ -2275,7 +2275,7 @@ impl OutboundPayments {
continue 'path_check;
}
let dest_hop_idx = if path.blinded_tail.is_some() && path.blinded_tail.as_ref().unwrap().hops.len() > 1 {
- usize::max_value() } else { path.hops.len() - 1 };
+ usize::MAX } else { path.hops.len() - 1 };
for (idx, hop) in path.hops.iter().enumerate() {
if idx != dest_hop_idx && hop.pubkey == our_node_id {
path_errs.push(Err(APIError::InvalidRoute{err: "Path went through us but wasn't a simple rebalance loop to us".to_owned()}));
### lightning/src/ln/peer_channel_encryptor.rs
@@ -33,7 +33,7 @@ use crate::util::ser::VecWriter;
/// Maximum Lightning message data length according to
/// [BOLT-8](https://github.com/lightning/bolts/blob/v1.0/08-transport.md#lightning-message-specification)
/// and [BOLT-1](https://github.com/lightning/bolts/blob/master/01-messaging.md#lightning-message-format):
-pub const LN_MAX_MSG_LEN: usize = ::core::u16::MAX as usize; // Must be equal to 65535
+pub const LN_MAX_MSG_LEN: usize = u16::MAX as usize; // Must be equal to 65535
/// The (rough) size buffer to pre-allocate when encoding a message. Messages should reliably be
/// smaller than this size by at least 32 bytes or so.
@@ -1062,7 +1062,7 @@ mod tests {
#[test]
fn max_msg_len_limit_value() {
assert_eq!(LN_MAX_MSG_LEN, 65535);
- assert_eq!(LN_MAX_MSG_LEN, ::core::u16::MAX as usize);
+ assert_eq!(LN_MAX_MSG_LEN, u16::MAX as usize);
}
#[test]
### lightning/src/ln/peer_handler.rs
@@ -3656,8 +3656,7 @@ impl<
// be absurd. We ensure this by checking that at least 100 (our stated public contract on when
// broadcast_node_announcement panics) of the maximum-length addresses would fit in a 64KB
// message...
- const HALF_MESSAGE_IS_ADDRS: u32 =
- ::core::u16::MAX as u32 / (SocketAddress::MAX_LEN as u32 + 1) / 2;
+ const HALF_MESSAGE_IS_ADDRS: u32 = u16::MAX as u32 / (SocketAddress::MAX_LEN as u32 + 1) / 2;
#[allow(dead_code)]
// ...by failing to compile if the number of addresses that would be half of a message is
// smaller than 100:
### lightning/src/ln/wire.rs
@@ -724,11 +724,11 @@ mod tests {
#[test]
fn read_unknown_message() {
- let buffer = &::core::u16::MAX.to_be_bytes();
+ let buffer = &u16::MAX.to_be_bytes();
let message = read(&mut &buffer[..], &IgnoringMessageHandler {}).unwrap();
match message {
- Message::Unknown(::core::u16::MAX) => (),
- _ => panic!("Expected message type {}; found: {}", ::core::u16::MAX, message.type_id()),
+ Message::Unknown(u16::MAX) => (),
+ _ => panic!("Expected message type {}; found: {}", u16::MAX, message.type_id()),
}
}
### lightning/src/offers/invoice.rs
@@ -2224,7 +2224,7 @@ mod tests {
let secp_ctx = Secp256k1::new();
let payment_id = PaymentId([1; 32]);
- let future_expiry = Duration::from_secs(u64::max_value());
+ let future_expiry = Duration::from_secs(u64::MAX);
let past_expiry = Duration::from_secs(0);
if let Err(e) = OfferBuilder::new(recipient_pubkey())
@@ -2263,7 +2263,7 @@ mod tests {
#[cfg(feature = "std")]
#[test]
fn builds_invoice_from_refund_with_expiration() {
- let future_expiry = Duration::from_secs(u64::max_value());
+ let future_expiry = Duration::from_secs(u64::MAX);
let past_expiry = Duration::from_secs(0);
if let Err(e) = RefundBuilder::new(vec![1; 32], payer_pubkey(), 1000)
@@ -2534,7 +2534,7 @@ mod tests {
.unwrap()
.request_invoice(&expanded_key, nonce, &secp_ctx, payment_id)
.unwrap()
- .quantity(u64::max_value())
+ .quantity(u64::MAX)
.unwrap()
.build_unchecked_and_sign()
.respond_with_no_std(payment_paths(), payment_hash(), now())
### lightning/src/offers/invoice_request.rs
@@ -1680,7 +1680,7 @@ mod tests {
let secp_ctx = Secp256k1::new();
let payment_id = PaymentId([1; 32]);
- let future_expiry = Duration::from_secs(u64::max_value());
+ let future_expiry = Duration::from_secs(u64::MAX);
let past_expiry = Duration::from_secs(0);
if let Err(e) = OfferBuilder::new(recipient_pubkey())
@@ -2051,7 +2051,7 @@ mod tests {
.unwrap()
.request_invoice(&expanded_key, nonce, &secp_ctx, payment_id)
.unwrap()
- .quantity(u64::max_value())
+ .quantity(u64::MAX)
.unwrap()
.build_and_sign()
{
@@ -2518,7 +2518,7 @@ mod tests {
.unwrap()
.request_invoice(&expanded_key, nonce, &secp_ctx, payment_id)
.unwrap()
- .quantity(u64::max_value())
+ .quantity(u64::MAX)
.unwrap()
.build_unchecked_and_sign();
### lightning/src/offers/offer.rs
@@ -1756,7 +1756,7 @@ mod tests {
#[test]
fn builds_offer_with_absolute_expiry() {
- let future_expiry = Duration::from_secs(u64::max_value());
+ let future_expiry = Duration::from_secs(u64::MAX);
let past_expiry = Duration::from_secs(0);
let now = future_expiry - Duration::from_secs(1_000);
### lightning/src/offers/refund.rs
@@ -1287,7 +1287,7 @@ mod tests {
#[test]
fn builds_refund_with_absolute_expiry() {
- let future_expiry = Duration::from_secs(u64::max_value());
+ let future_expiry = Duration::from_secs(u64::MAX);
let past_expiry = Duration::from_secs(0);
let now = future_expiry - Duration::from_secs(1_000);
### lightning/src/offers/static_invoice.rs
@@ -954,7 +954,7 @@ mod tests {
let nonce = Nonce::from_entropy_source(&entropy);
let secp_ctx = Secp256k1::new();
- let future_expiry = Duration::from_secs(u64::max_value());
+ let future_expiry = Duration::from_secs(u64::MAX);
let past_expiry = Duration::from_secs(0);
let valid_offer =
### lightning/src/routing/gossip.rs
@@ -862,7 +862,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, U: UtxoLookup, L: Logger> BaseMessageHa
msg: GossipTimestampFilter {
chain_hash: self.network_graph.chain_hash,
first_timestamp: gossip_start_time as u32, // 2106 issue!
- timestamp_range: u32::max_value(),
+ timestamp_range: u32::MAX,
},
});
Ok(())
@@ -1188,8 +1188,8 @@ impl Readable for ChannelInfo {
announcement_received_time,
(default_value, 0)
),
- node_one_counter: u32::max_value(),
- node_two_counter: u32::max_value(),
+ node_one_counter: u32::MAX,
+ node_two_counter: u32::MAX,
})
}
}
@@ -1344,7 +1344,7 @@ impl EffectiveCapacity {
EffectiveCapacity::AdvertisedMaxHTLC { amount_msat } => *amount_msat,
EffectiveCapacity::Total { capacity_msat, .. } => *capacity_msat,
EffectiveCapacity::HintMaxHTLC { amount_msat } => *amount_msat,
- EffectiveCapacity::Infinite => u64::max_value(),
+ EffectiveCapacity::Infinite => u64::MAX,
EffectiveCapacity::Unknown => UNKNOWN_CHANNEL_CAPACITY_MSAT,
}
}
@@ -1624,7 +1624,7 @@ impl Readable for NodeInfo {
Ok(NodeInfo {
announcement_info: announcement_info_wrap.map(|w| w.0),
channels,
- node_counter: u32::max_value(),
+ node_counter: u32::MAX,
})
}
}
@@ -1683,7 +1683,7 @@ impl<L: Logger> ReadableArgs<L> for NetworkGraph<L> {
let nodes_count: u64 = Readable::read(reader)?;
// There shouldn't be anywhere near `u32::MAX` nodes, and we need some headroom to insert
// new nodes during sync, so reject any graphs claiming more than `u32::MAX / 2` nodes.
- if nodes_count > u32::max_value() as u64 / 2 {
+ if nodes_count > u32::MAX as u64 / 2 {
return Err(DecodeError::InvalidValue);
}
// Pre-allocate 115% of the known channel count to avoid unnecessary reallocations.
@@ -1804,7 +1804,7 @@ impl<L: Logger> NetworkGraph<L> {
let nodes = self.nodes.read().unwrap();
let removed_node_counters = self.removed_node_counters.lock().unwrap();
let next_counter = self.next_node_counter.load(Ordering::Acquire);
- assert!(next_counter < (u32::max_value() as usize) / 2);
+ assert!(next_counter < (u32::MAX as usize) / 2);
let mut used_node_counters = vec![0u8; next_counter / 8 + 1];
for counter in removed_node_counters.iter() {
@@ -2031,8 +2031,8 @@ impl<L: Logger> NetworkGraph<L> {
capacity_sats,
announcement_message: None,
announcement_received_time: timestamp,
- node_one_counter: u32::max_value(),
- node_two_counter: u32::max_value(),
+ node_one_counter: u32::MAX,
+ node_two_counter: u32::MAX,
};
self.add_channel_between_nodes(short_channel_id, channel_info, None)
@@ -2224,8 +2224,8 @@ impl<L: Logger> NetworkGraph<L> {
None
},
announcement_received_time,
- node_one_counter: u32::max_value(),
- node_two_counter: u32::max_value(),
+ node_one_counter: u32::MAX,
+ node_two_counter: u32::MAX,
};
self.add_channel_between_nodes(msg.short_channel_id, chan_info, utxo_value)?;
@@ -2356,7 +2356,7 @@ impl<L: Logger> NetworkGraph<L> {
pub fn remove_stale_channels_and_tracking_with_time(&self, current_time_unix: u64) {
let mut channels = self.channels.write().unwrap();
// Time out if we haven't received an update in at least 14 days.
- if current_time_unix > u32::max_value() as u64 {
+ if current_time_unix > u32::MAX as u64 {
return;
} // Remove by 2106
if current_time_unix < STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS {
@@ -3933,7 +3933,7 @@ pub(crate) mod tests {
(msg.first_timestamp as u64)
< expected_timestamp - 60 * 60 * 24 * 7 * 2 + 10
);
- assert_eq!(msg.timestamp_range, u32::max_value());
+ assert_eq!(msg.timestamp_range, u32::MAX);
},
_ => panic!("Expected MessageSendEvent::SendChannelRangeQuery"),
};
### lightning/src/routing/router.rs
@@ -860,7 +860,7 @@ impl Readable for Route {
let path_count: u64 = Readable::read(reader)?;
if path_count == 0 { return Err(DecodeError::InvalidValue); }
let mut paths = Vec::with_capacity(cmp::min(path_count, 128) as usize);
- let mut min_final_cltv_expiry_delta = u32::max_value();
+ let mut min_final_cltv_expiry_delta = u32::MAX;
for _ in 0..path_count {
let hop_count: u8 = Readable::read(reader)?;
let mut hops: Vec<RouteHop> = Vec::with_capacity(hop_count as usize);
@@ -2172,7 +2172,7 @@ fn max_htlc_from_capacity(capacity: EffectiveCapacity, max_channel_saturation_po
let saturation_shift: u32 = max_channel_saturation_power_of_half as u32;
match capacity {
EffectiveCapacity::ExactLiquidity { liquidity_msat } => liquidity_msat,
- EffectiveCapacity::Infinite => u64::max_value(),
+ EffectiveCapacity::Infinite => u64::MAX,
EffectiveCapacity::Unknown => EffectiveCapacity::Unknown.as_msat(),
EffectiveCapacity::AdvertisedMaxHTLC { amount_msat } =>
amount_msat.checked_shr(saturation_shift).unwrap_or(0),
@@ -2290,7 +2290,7 @@ impl<'a> PaymentPath<'a> {
}
fn get_path_penalty_msat(&self) -> u64 {
- self.hops.first().map(|h| h.0.path_penalty_msat).unwrap_or(u64::max_value())
+ self.hops.first().map(|h| h.0.path_penalty_msat).unwrap_or(u64::MAX)
}
fn get_total_fee_paid_msat(&self) -> u64 {
@@ -2464,7 +2464,7 @@ impl<'a> PaymentPath<'a> {
fn mark_candidate_liquidity_exhausted(
used_liquidities: &mut HashMap<CandidateHopId, u64>, candidate: &CandidateRouteHop,
) {
- let exhausted = u64::max_value();
+ let exhausted = u64::MAX;
if let Some(scid) = candidate.short_channel_id() {
*used_liquidities.entry(CandidateHopId::Clear((scid, false))).or_default() = exhausted;
*used_liquidities.entry(CandidateHopId::Clear((scid, true))).or_default() = exhausted;
@@ -2483,11 +2483,11 @@ pub(crate) fn compute_fees(amount_msat: u64, channel_fees: RoutingFees) -> Optio
#[inline(always)]
/// Calculate the fees required to route the given amount over a channel with the given fees,
-/// saturating to [`u64::max_value`].
+/// saturating to [`u64::MAX`].
#[rustfmt::skip]
fn compute_fees_saturating(amount_msat: u64, channel_fees: RoutingFees) -> u64 {
amount_msat.checked_mul(channel_fees.proportional_millionths as u64)
- .map(|prop| prop / 1_000_000).unwrap_or(u64::max_value())
+ .map(|prop| prop / 1_000_000).unwrap_or(u64::MAX)
.saturating_add(channel_fees.base_msat as u64)
}
@@ -2746,7 +2746,7 @@ pub(crate) fn get_route<L: Logger, S: ScoreLookUp>(
network_nodes.get(&payee).is_some_and(|node| node.announcement_info.as_ref().is_some_and(|info| info.features().supports_basic_mpp()))
} else { false };
- let max_total_routing_fee_msat = route_params.max_total_routing_fee_msat.unwrap_or(u64::max_value());
+ let max_total_routing_fee_msat = route_params.max_total_routing_fee_msat.unwrap_or(u64::MAX);
let first_hop_count = first_hops.map(|hops| hops.len()).unwrap_or(0);
log_trace!(logger, "Searching for a route from payer {} to {} {} MPP and {} first hops {}overriding the network graph of {} nodes and {} channels with a fee limit of {} msat",
@@ -3125,11 +3125,11 @@ pub(crate) fn get_route<L: Logger, S: ScoreLookUp>(
*dist_entry = Some(PathBuildingHop {
candidate: $candidate.clone(),
fee_msat: 0,
- next_hops_fee_msat: u64::max_value(),
- hop_use_fee_msat: u64::max_value(),
- total_fee_msat: u64::max_value(),
+ next_hops_fee_msat: u64::MAX,
+ hop_use_fee_msat: u64::MAX,
+ total_fee_msat: u64::MAX,
path_htlc_minimum_msat,
- path_penalty_msat: u64::max_value(),
+ path_penalty_msat: u64::MAX,
was_processed: false,
is_first_hop_target: false,
is_last_hop_target: false,
@@ -3156,7 +3156,7 @@ pub(crate) fn get_route<L: Logger, S: ScoreLookUp>(
// Ignore hop_use_fee_msat for channel-from-us as we assume all channels-from-us
// will have the same effective-fee
if src_node_id != our_node_id {
- // Note that `u64::max_value` means we'll always fail the
+ // Note that `u64::MAX` means we'll always fail the
// `old_entry.total_fee_msat > total_fee_msat` check below
hop_use_fee_msat = compute_fees_saturating(amount_to_transfer_over_msat, candidate_fees);
total_fee_msat = total_fee_msat.saturating_add(hop_use_fee_msat);
@@ -3437,15 +3437,15 @@ pub(crate) fn get_route<L: Logger, S: ScoreLookUp>(
candidate: CandidateRouteHop::FirstHop(FirstHopCandidate {
details: &chans[0],
payer_node_id: &our_node_id,
- target_node_counter: u32::max_value(),
- payer_node_counter: u32::max_value(),
+ target_node_counter: u32::MAX,
+ payer_node_counter: u32::MAX,
}),
fee_msat: 0,
- next_hops_fee_msat: u64::max_value(),
- hop_use_fee_msat: u64::max_value(),
- total_fee_msat: u64::max_value(),
- path_htlc_minimum_msat: u64::max_value(),
- path_penalty_msat: u64::max_value(),
+ next_hops_fee_msat: u64::MAX,
+ hop_use_fee_msat: u64::MAX,
+ total_fee_msat: u64::MAX,
+ path_htlc_minimum_msat: u64::MAX,
+ path_penalty_msat: u64::MAX,
was_processed: false,
is_first_hop_target: true,
is_last_hop_target: false,
@@ -3470,11 +3470,11 @@ pub(crate) fn get_route<L: Logger, S: ScoreLookUp>(
*entry = Some(PathBuildingHop {
candidate: candidates[0].clone(),
fee_msat: 0,
- next_hops_fee_msat: u64::max_value(),
- hop_use_fee_msat: u64::max_value(),
- total_fee_msat: u64::max_value(),
- path_htlc_minimum_msat: u64::max_value(),
- path_penalty_msat: u64::max_value(),
+ next_hops_fee_msat: u64::MAX,
+ hop_use_fee_msat: u64::MAX,
+ total_fee_msat: u64::MAX,
+ path_htlc_minimum_msat: u64::MAX,
+ path_penalty_msat: u64::MAX,
was_processed: false,
is_first_hop_target: false,
is_last_hop_target: true,
@@ -3687,7 +3687,7 @@ pub(crate) fn get_route<L: Logger, S: ScoreLookUp>(
// we'll probably end up picking the same path again on the next iteration.
// Decrease the available liquidity of a hop in the middle of the path.
let victim_candidate = &payment_path.hops[(payment_path.hops.len()) / 2].0.candidate;
- let exhausted = u64::max_value();
+ let exhausted = u64::MAX;
log_trace!(logger,
"Disabling route candidate {} for future path building iterations to avoid duplicates.",
LoggedCandidateHop(victim_candidate));
@@ -4070,7 +4070,7 @@ fn build_route_from_hops_internal<L: Logger>(
break;
}
}
- u64::max_value()
+ u64::MAX
}
}
@@ -6819,8 +6819,8 @@ mod tests {
cltv_expiry_delta: (5 << 4) | 5,
htlc_minimum_msat: 0,
htlc_maximum_msat: 99_000,
- fee_base_msat: u32::max_value(),
- fee_proportional_millionths: u32::max_value(),
+ fee_base_msat: u32::MAX,
+ fee_proportional_millionths: u32::MAX,
excess_data: Vec::new()
});
update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
@@ -6832,8 +6832,8 @@ mod tests {
cltv_expiry_delta: (5 << 4) | 3,
htlc_minimum_msat: 0,
htlc_maximum_msat: 99_000,
- fee_base_msat: u32::max_value(),
- fee_proportional_millionths: u32::max_value(),
+ fee_base_msat: u32::MAX,
+ fee_proportional_millionths: u32::MAX,
excess_data: Vec::new()
});
update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
@@ -7486,7 +7486,7 @@ mod tests {
type ScoreParams = ();
#[rustfmt::skip]
fn channel_penalty_msat(&self, candidate: &CandidateRouteHop, _: ChannelUsage, _score_params:&Self::ScoreParams) -> u64 {
- if candidate.short_channel_id() == Some(self.short_channel_id) { u64::max_value() } else { 0 }
+ if candidate.short_channel_id() == Some(self.short_channel_id) { u64::MAX } else { 0 }
}
}
@@ -7504,7 +7504,7 @@ mod tests {
type ScoreParams = ();
#[rustfmt::skip]
fn channel_penalty_msat(&self, candidate: &CandidateRouteHop, _: ChannelUsage, _score_params:&Self::ScoreParams) -> u64 {
- if candidate.target() == Some(self.node_id) { u64::max_value() } else { 0 }
+ if candidate.target() == Some(self.node_id) { u64::MAX } else { 0 }
}
}
### lightning/src/routing/scoring.rs
@@ -102,7 +102,7 @@ pub trait ScoreLookUp {
/// The channel's capacity (less any other MPP parts that are also being considered for use in
/// the same payment) is given by `capacity_msat`. It may be determined from various sources
/// such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near
- /// [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount.
+ /// [`u64::MAX`] is given to indicate sufficient capacity for the invoice's full amount.
/// Thus, implementations should be overflow-safe.
fn channel_penalty_msat(
&self, candidate: &CandidateRouteHop, usage: ChannelUsage, score_params: &Self::ScoreParams
@@ -622,7 +622,7 @@ pub struct ProbabilisticScoringFeeParameters {
/// penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to
/// lower bounding the success probability to `0.01`) when the amount falls within the
/// uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will
- /// result in a `u64::max_value` penalty, however.
+ /// result in a `u64::MAX` penalty, however.
///
/// `-log10(success_probability) * liquidity_penalty_multiplier_msat`
///
@@ -703,7 +703,7 @@ pub struct ProbabilisticScoringFeeParameters {
pub historical_liquidity_penalty_amount_multiplier_msat: u64,
/// Manual penalties used for the given nodes. Allows to set a particular penalty for a given
- /// node. Note that a manual penalty of `u64::max_value()` means the node would not ever be
+ /// node. Note that a manual penalty of `u64::MAX` means the node would not ever be
/// considered during path finding.
///
/// This is not exported to bindings users
@@ -728,7 +728,7 @@ pub struct ProbabilisticScoringFeeParameters {
/// applicable, are still included in the overall penalty.
///
/// If you wish to avoid creating paths with such channels entirely, setting this to a value of
- /// `u64::max_value()` will guarantee that.
+ /// `u64::MAX` will guarantee that.
///
/// Default value: 1_0000_0000_000 msat (1 Bitcoin)
///
@@ -806,14 +806,14 @@ impl ProbabilisticScoringFeeParameters {
/// Marks the node with the given `node_id` as banned,
/// i.e it will be avoided during path finding.
pub fn add_banned(&mut self, node_id: &NodeId) {
- self.manual_node_penalties.insert(*node_id, u64::max_value());
+ self.manual_node_penalties.insert(*node_id, u64::MAX);
}
/// Marks all nodes in the given list as banned, i.e.,
/// they will be avoided during path finding.
pub fn add_banned_from_list(&mut self, node_ids: Vec<NodeId>) {
for id in node_ids {
- self.manual_node_penalties.insert(id, u64::max_value());
+ self.manual_node_penalties.insert(id, u64::MAX);
}
}
@@ -1381,7 +1381,7 @@ fn linear_success_probability(
if min_zero_implies_no_successes
&& min_liquidity_msat == 0
- && denominator < u64::max_value() / MIN_ZERO_IMPLIES_NO_SUCCESSES_PENALTY_ON_64
+ && denominator < u64::MAX / MIN_ZERO_IMPLIES_NO_SUCCESSES_PENALTY_ON_64
{
denominator = denominator * MIN_ZERO_IMPLIES_NO_SUCCESSES_PENALTY_ON_64 / 64
}
@@ -1724,7 +1724,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Logger> ScoreLookUp for Probabilisti
let total_inflight_amount_msat =
usage.amount_msat.saturating_add(usage.inflight_htlc_msat);
if usage.amount_msat > hint.payinfo.htlc_maximum_msat {
- return u64::max_value();
+ return u64::MAX;
} else if total_inflight_amount_msat > hint.payinfo.htlc_maximum_msat {
return score_params.considered_impossible_penalty_msat;
} else {
@@ -1748,7 +1748,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Logger> ScoreLookUp for Probabilisti
EffectiveCapacity::HintMaxHTLC { amount_msat } =>
{
if usage.amount_msat > amount_msat {
- return u64::max_value();
+ return u64::MAX;
} else {
return base_penalty_msat;
}
@@ -1851,7 +1851,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Logger> ScoreUpdate for Probabilisti
}
fn probe_successful(&mut self, path: &Path, duration_since_epoch: Duration) {
- self.payment_path_failed(path, u64::max_value(), duration_since_epoch)
+ self.payment_path_failed(path, u64::MAX, duration_since_epoch)
}
fn time_passed(&mut self, duration_since_epoch: Duration) {
@@ -2075,7 +2075,7 @@ mod bucketed_history {
#[inline]
#[rustfmt::skip]
fn amount_to_pos(amount_msat: u64, capacity_msat: u64) -> u16 {
- let pos = if amount_msat < u64::max_value() / (POSITION_TICKS as u64) {
+ let pos = if amount_msat < u64::MAX / (POSITION_TICKS as u64) {
(amount_msat * (POSITION_TICKS as u64) / capacity_msat.saturating_add(1))
.try_into().unwrap_or(POSITION_TICKS)
} else {
@@ -3117,7 +3117,7 @@ mod tests {
let network_graph = network_graph(&logger);
let params = ProbabilisticScoringFeeParameters {
liquidity_penalty_multiplier_msat: 1_000,
- considered_impossible_penalty_msat: u64::max_value(),
+ considered_impossible_penalty_msat: u64::MAX,
..ProbabilisticScoringFeeParameters::zero_penalty()
};
let decay_params = ProbabilisticScoringDecayParameters {
@@ -3146,9 +3146,9 @@ mod tests {
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), 0);
let usage = ChannelUsage { amount_msat: 50, ..usage };
assert_ne!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), 0);
- assert_ne!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_ne!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
let usage = ChannelUsage { amount_msat: 61, ..usage };
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
}
#[test]
@@ -3232,7 +3232,7 @@ mod tests {
let network_graph = network_graph(&logger);
let params = ProbabilisticScoringFeeParameters {
liquidity_penalty_multiplier_msat: 1_000,
- considered_impossible_penalty_msat: u64::max_value(),
+ considered_impossible_penalty_msat: u64::MAX,
..ProbabilisticScoringFeeParameters::zero_penalty()
};
let mut scorer = ProbabilisticScorer::new(ProbabilisticScoringDecayParameters::default(), &network_graph, &logger);
@@ -3263,9 +3263,9 @@ mod tests {
let usage = ChannelUsage { amount_msat: 500, ..usage };
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), 2000);
let usage = ChannelUsage { amount_msat: 501, ..usage };
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
let usage = ChannelUsage { amount_msat: 750, ..usage };
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
}
#[test]
@@ -3414,7 +3414,7 @@ mod tests {
let network_graph = network_graph(&logger);
let params = ProbabilisticScoringFeeParameters {
liquidity_penalty_multiplier_msat: 1_000,
- considered_impossible_penalty_msat: u64::max_value(),
+ considered_impossible_penalty_msat: u64::MAX,
..ProbabilisticScoringFeeParameters::zero_penalty()
};
let decay_params = ProbabilisticScoringDecayParameters {
@@ -3450,7 +3450,7 @@ mod tests {
let usage = ChannelUsage { amount_msat: 768, ..usage };
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), 1_479);
let usage = ChannelUsage { amount_msat: 896, ..usage };
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
// Half decay (i.e., three-quarter life)
scorer.time_passed(Duration::from_secs(5));
@@ -3461,7 +3461,7 @@ mod tests {
let usage = ChannelUsage { amount_msat: 768, ..usage };
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), 921);
let usage = ChannelUsage { amount_msat: 896, ..usage };
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
// One decay (i.e., half life)
scorer.time_passed(Duration::from_secs(10));
@@ -3472,7 +3472,7 @@ mod tests {
let usage = ChannelUsage { amount_msat: 896, ..usage };
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), 1_970);
let usage = ChannelUsage { amount_msat: 960, ..usage };
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
// Fully decay liquidity lower bound.
scorer.time_passed(Duration::from_secs(10 * 8));
@@ -3483,20 +3483,20 @@ mod tests {
let usage = ChannelUsage { amount_msat: 1_024, ..usage };
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), 2_000);
let usage = ChannelUsage { amount_msat: 1_025, ..usage };
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
// Fully decay liquidity upper bound.
scorer.time_passed(Duration::from_secs(10 * 9));
let usage = ChannelUsage { amount_msat: 0, ..usage };
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), 0);
let usage = ChannelUsage { amount_msat: 1_025, ..usage };
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
scorer.time_passed(Duration::from_secs(10 * 10));
let usage = ChannelUsage { amount_msat: 0, ..usage };
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), 0);
let usage = ChannelUsage { amount_msat: 1_025, ..usage };
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
}
#[test]
@@ -3559,7 +3559,7 @@ mod tests {
let network_graph = network_graph(&logger);
let params = ProbabilisticScoringFeeParameters {
liquidity_penalty_multiplier_msat: 1_000,
- considered_impossible_penalty_msat: u64::max_value(),
+ considered_impossible_penalty_msat: u64::MAX,
..ProbabilisticScoringFeeParameters::zero_penalty()
};
let decay_params = ProbabilisticScoringDecayParameters {
@@ -3581,7 +3581,7 @@ mod tests {
info,
short_channel_id: 42,
});
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
scorer.time_passed(Duration::from_secs(10));
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), 477);
@@ -3604,7 +3604,7 @@ mod tests {
let network_graph = network_graph(&logger);
let params = ProbabilisticScoringFeeParameters {
liquidity_penalty_multiplier_msat: 1_000,
- considered_impossible_penalty_msat: u64::max_value(),
+ considered_impossible_penalty_msat: u64::MAX,
..ProbabilisticScoringFeeParameters::zero_penalty()
};
let decay_params = ProbabilisticScoringDecayParameters {
@@ -3632,7 +3632,7 @@ mod tests {
amount_msat: 501,
..usage
};
- assert_eq!(scorer.channel_penalty_msat(&candidate, over_usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, over_usage, ¶ms), u64::MAX);
if decay_before_reload {
scorer.time_passed(Duration::from_secs(10));
@@ -3812,7 +3812,7 @@ mod tests {
let network_graph = network_graph(&logger);
let source = source_node_id();
let usage = ChannelUsage {
- amount_msat: u64::max_value(),
+ amount_msat: u64::MAX,
inflight_htlc_msat: 0,
effective_capacity: EffectiveCapacity::Infinite,
};
@@ -3837,7 +3837,7 @@ mod tests {
let logger = TestLogger::new();
let network_graph = network_graph(&logger);
let params = ProbabilisticScoringFeeParameters {
- considered_impossible_penalty_msat: u64::max_value(),
+ considered_impossible_penalty_msat: u64::MAX,
..ProbabilisticScoringFeeParameters::zero_penalty()
};
let scorer = ProbabilisticScorer::new(ProbabilisticScoringDecayParameters::default(), &network_graph, &logger);
@@ -3855,10 +3855,10 @@ mod tests {
info,
short_channel_id: 42,
});
- assert_ne!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_ne!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
let usage = ChannelUsage { inflight_htlc_msat: 251, ..usage };
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
}
#[test]
@@ -3889,7 +3889,7 @@ mod tests {
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), base_penalty_msat);
let usage = ChannelUsage { amount_msat: 1_001, ..usage };
- assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::max_value());
+ assert_eq!(scorer.channel_penalty_msat(&candidate, usage, ¶ms), u64::MAX);
}
#[test]
### lightning/src/routing/test_utils.rs
@@ -362,8 +362,8 @@ fn do_build_graph(with_validation: bool) -> (
cltv_expiry_delta: (5 << 4) | 3,
htlc_minimum_msat: 0,
htlc_maximum_msat: MAX_VALUE_MSAT,
- fee_base_msat: u32::max_value(),
- fee_proportional_millionths: u32::max_value(),
+ fee_base_msat: u32::MAX,
+ fee_proportional_millionths: u32::MAX,
excess_data: Vec::new()
});
update_channel(&gossip_sync, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
@@ -392,8 +392,8 @@ fn do_build_graph(with_validation: bool) -> (
cltv_expiry_delta: (5 << 4) | 3,
htlc_minimum_msat: 0,
htlc_maximum_msat: MAX_VALUE_MSAT,
- fee_base_msat: u32::max_value(),
- fee_proportional_millionths: u32::max_value(),
+ fee_base_msat: u32::MAX,
+ fee_proportional_millionths: u32::MAX,
excess_data: Vec::new()
});
update_channel(&gossip_sync, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
### lightning/src/sign/mod.rs
@@ -2481,7 +2481,7 @@ impl SignerProvider for KeysManager {
// roll over, we may generate duplicate keys for two different channels, which could result
// in loss of funds. Because we only support 32-bit+ systems, assert that our `AtomicUsize`
// doesn't reach `u32::MAX`.
- assert!(child_idx < core::u32::MAX as usize, "2^32 channels opened without restart");
+ assert!(child_idx < u32::MAX as usize, "2^32 channels opened without restart");
let mut id = [0; 32];
id[0..4].copy_from_slice(&(child_idx as u32).to_be_bytes());
id[4..8].copy_from_slice(&self.starting_time_nanos.to_be_bytes());
### lightning/src/sign/tx_builder.rs
@@ -626,10 +626,10 @@ fn adjust_min_max_htlc_for_dust_exposure(
}
if local_dust_exposure_msat as i64 + buffer_dust_limit_timeout_sat as i64 * 1000 - 1
- > max_dust_htlc_exposure_msat.try_into().unwrap_or(i64::max_value())
+ > max_dust_htlc_exposure_msat.try_into().unwrap_or(i64::MAX)
{
remaining_msat_below_dust_exposure_limit = Some(cmp::min(
- remaining_msat_below_dust_exposure_limit.unwrap_or(u64::max_value()),
+ remaining_msat_below_dust_exposure_limit.unwrap_or(u64::MAX),
max_dust_htlc_exposure_msat.saturating_sub(local_dust_exposure_msat),
));
dust_exposure_dust_limit_msat =
### lightning/src/util/config.rs
@@ -313,7 +313,7 @@ impl Readable for ChannelHandshakeConfig {
///
/// These limits are only applied to our counterparty's limits, not our own.
///
-/// Use `0` or `<type>::max_value()` as appropriate to skip checking.
+/// Use `0` or `<type>::MAX` as appropriate to skip checking.
///
/// Provides sane defaults for most configurations.
///
@@ -333,7 +333,7 @@ pub struct ChannelHandshakeLimits {
/// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
/// you to limit the maximum minimum-size they can require.
///
- /// Default value: `u64::max_value`
+ /// Default value: `u64::MAX`
pub max_htlc_minimum_msat: u64,
/// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
/// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
@@ -344,7 +344,7 @@ pub struct ChannelHandshakeLimits {
/// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
/// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
///
- /// Default value: `u64::max_value`.
+ /// Default value: `u64::MAX`.
pub max_channel_reserve_satoshis: u64,
/// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
/// time. This allows you to set a minimum such value.
### lightning/src/util/test_utils.rs
@@ -264,8 +264,8 @@ impl<'a> Router for TestRouter<'a> {
CandidateRouteHop::FirstHop(FirstHopCandidate {
details: first_hops[idx],
payer_node_id: &node_id,
- payer_node_counter: u32::max_value(),
- target_node_counter: u32::max_value(),
+ payer_node_counter: u32::MAX,
+ target_node_counter: u32::MAX,
});
scorer.channel_penalty_msat(
&candidate,
@@ -300,8 +300,8 @@ impl<'a> Router for TestRouter<'a> {
CandidateRouteHop::PrivateHop(PrivateHopCandidate {
hint: &route_hint,
target_node_id: &target_node_id,
- source_node_counter: u32::max_value(),
- target_node_counter: u32::max_value(),
+ source_node_counter: u32::MAX,
+ target_node_counter: u32::MAX,
});
scorer.channel_penalty_msat(&candidate, usage, &Default::default());
}
@@ -1747,7 +1747,7 @@ impl BaseMessageHandler for TestRoutingMessageHandler {
msg: msgs::GossipTimestampFilter {
chain_hash: ChainHash::using_genesis_block(Network::Testnet),
first_timestamp: gossip_start_time as u32,
- timestamp_range: u32::max_value(),
+ timestamp_range: u32::MAX,
},
});
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.