Skip to content

Commit

Permalink
use saturating_len where possible (#2316)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored and bkontur committed May 23, 2024
1 parent 71d3e6b commit 34e1590
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bridges/modules/messages/src/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn verify_messages_proof<T: Config<I>, I: 'static>(
let nonces_range = nonces_start..=nonces_end;

// receiving proofs where end < begin is ok (if proof includes outbound lane state)
let messages_in_the_proof = nonces_range.checked_len().unwrap_or(0);
let messages_in_the_proof = nonces_range.saturating_len();
if messages_in_the_proof != MessageNonce::from(messages_count) {
return Err(VerificationError::MessagesCountMismatch)
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/messages/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl crate::benchmarking::Config<()> for TestRuntime {
use bp_runtime::RangeInclusiveExt;

let dispatch_weight =
REGULAR_PAYLOAD.declared_weight * params.message_nonces.checked_len().unwrap_or(0);
REGULAR_PAYLOAD.declared_weight * params.message_nonces.saturating_len();
(
*prepare_messages_proof(
params.message_nonces.into_iter().map(|n| message(n, REGULAR_PAYLOAD)).collect(),
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/xcm-bridge-hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ pub mod pallet {
outbound_lane.set_state(LaneState::Closed);

// write something to log
let enqueued_messages = outbound_lane.queued_messages().checked_len().unwrap_or(0);
let enqueued_messages = outbound_lane.queued_messages().saturating_len();
log::trace!(
target: LOG_TARGET,
"Bridge {:?} between {:?} and {:?} is closing. {} messages remaining",
Expand Down

0 comments on commit 34e1590

Please sign in to comment.