mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 23:15:42 +00:00
@@ -97,7 +97,7 @@ fn slot_author<P: Pair>(slot: Slot, authorities: &[AuthorityId<P>]) -> Option<&A
|
||||
|
||||
let idx = *slot % (authorities.len() as u64);
|
||||
assert!(
|
||||
idx <= usize::max_value() as u64,
|
||||
idx <= usize::MAX as u64,
|
||||
"It is impossible to have a vector with length beyond the address space; qed",
|
||||
);
|
||||
|
||||
|
||||
@@ -1468,7 +1468,7 @@ impl<Block: BlockT> GossipValidator<Block> {
|
||||
"" => "",
|
||||
);
|
||||
|
||||
let len = std::cmp::min(i32::max_value() as usize, data.len()) as i32;
|
||||
let len = std::cmp::min(i32::MAX as usize, data.len()) as i32;
|
||||
Action::Discard(Misbehavior::UndecodablePacket(len).cost())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ fn speed<B: BlockT>(
|
||||
// algebraic approach and we stay within the realm of integers.
|
||||
let one_thousand = NumberFor::<B>::from(1_000u32);
|
||||
let elapsed = NumberFor::<B>::from(
|
||||
<u32 as TryFrom<_>>::try_from(elapsed_ms).unwrap_or(u32::max_value())
|
||||
<u32 as TryFrom<_>>::try_from(elapsed_ms).unwrap_or(u32::MAX)
|
||||
);
|
||||
|
||||
let speed = diff.saturating_mul(one_thousand).checked_div(&elapsed)
|
||||
|
||||
@@ -159,7 +159,7 @@ where TSubstream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
}
|
||||
|
||||
let mut codec = UviBytes::default();
|
||||
codec.set_max_len(usize::try_from(self.max_notification_size).unwrap_or(usize::max_value()));
|
||||
codec.set_max_len(usize::try_from(self.max_notification_size).unwrap_or(usize::MAX));
|
||||
|
||||
let substream = NotificationsInSubstream {
|
||||
socket: Framed::new(socket, codec),
|
||||
@@ -390,7 +390,7 @@ where TSubstream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
}
|
||||
|
||||
let mut codec = UviBytes::default();
|
||||
codec.set_max_len(usize::try_from(self.max_notification_size).unwrap_or(usize::max_value()));
|
||||
codec.set_max_len(usize::try_from(self.max_notification_size).unwrap_or(usize::MAX));
|
||||
|
||||
Ok(NotificationsOutOpen {
|
||||
handshake,
|
||||
|
||||
@@ -809,7 +809,7 @@ impl RequestResponseCodec for GenericCodec {
|
||||
// Read the length.
|
||||
let length = unsigned_varint::aio::read_usize(&mut io).await
|
||||
.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err))?;
|
||||
if length > usize::try_from(self.max_request_size).unwrap_or(usize::max_value()) {
|
||||
if length > usize::try_from(self.max_request_size).unwrap_or(usize::MAX) {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidInput,
|
||||
format!("Request size exceeds limit: {} > {}", length, self.max_request_size)
|
||||
@@ -846,7 +846,7 @@ impl RequestResponseCodec for GenericCodec {
|
||||
Err(err) => return Err(io::Error::new(io::ErrorKind::InvalidInput, err)),
|
||||
};
|
||||
|
||||
if length > usize::try_from(self.max_response_size).unwrap_or(usize::max_value()) {
|
||||
if length > usize::try_from(self.max_response_size).unwrap_or(usize::MAX) {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidInput,
|
||||
format!("Response size exceeds limit: {} > {}", length, self.max_response_size)
|
||||
|
||||
@@ -300,20 +300,20 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkWorker<B, H> {
|
||||
let yamux_maximum_buffer_size = {
|
||||
let requests_max = params.network_config
|
||||
.request_response_protocols.iter()
|
||||
.map(|cfg| usize::try_from(cfg.max_request_size).unwrap_or(usize::max_value()));
|
||||
.map(|cfg| usize::try_from(cfg.max_request_size).unwrap_or(usize::MAX));
|
||||
let responses_max = params.network_config
|
||||
.request_response_protocols.iter()
|
||||
.map(|cfg| usize::try_from(cfg.max_response_size).unwrap_or(usize::max_value()));
|
||||
.map(|cfg| usize::try_from(cfg.max_response_size).unwrap_or(usize::MAX));
|
||||
let notifs_max = params.network_config
|
||||
.extra_sets.iter()
|
||||
.map(|cfg| usize::try_from(cfg.max_notification_size).unwrap_or(usize::max_value()));
|
||||
.map(|cfg| usize::try_from(cfg.max_notification_size).unwrap_or(usize::MAX));
|
||||
|
||||
// A "default" max is added to cover all the other protocols: ping, identify,
|
||||
// kademlia, block announces, and transactions.
|
||||
let default_max = cmp::max(
|
||||
1024 * 1024,
|
||||
usize::try_from(protocol::BLOCK_ANNOUNCES_TRANSACTIONS_SUBSTREAM_SIZE)
|
||||
.unwrap_or(usize::max_value())
|
||||
.unwrap_or(usize::MAX)
|
||||
);
|
||||
|
||||
iter::once(default_max)
|
||||
|
||||
@@ -254,7 +254,7 @@ impl Metrics {
|
||||
.inc_by(num);
|
||||
self.notifications_sizes
|
||||
.with_label_values(&[protocol, "sent", name])
|
||||
.inc_by(num.saturating_mul(u64::try_from(message.len()).unwrap_or(u64::max_value())));
|
||||
.inc_by(num.saturating_mul(u64::try_from(message.len()).unwrap_or(u64::MAX)));
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -294,7 +294,7 @@ impl Metrics {
|
||||
.inc();
|
||||
self.notifications_sizes
|
||||
.with_label_values(&[&protocol, "received", name])
|
||||
.inc_by(u64::try_from(message.len()).unwrap_or(u64::max_value()));
|
||||
.inc_by(u64::try_from(message.len()).unwrap_or(u64::MAX));
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ fn lots_of_incoming_peers_works() {
|
||||
fallback_names: Vec::new(),
|
||||
max_notification_size: 1024 * 1024,
|
||||
set_config: config::SetConfig {
|
||||
in_peers: u32::max_value(),
|
||||
in_peers: u32::MAX,
|
||||
.. Default::default()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ struct Node {
|
||||
/// are indices into this `Vec`.
|
||||
sets: Vec<MembershipState>,
|
||||
|
||||
/// Reputation value of the node, between `i32::min_value` (we hate that node) and
|
||||
/// `i32::max_value` (we love that node).
|
||||
/// Reputation value of the node, between `i32::MIN` (we hate that node) and
|
||||
/// `i32::MAX` (we love that node).
|
||||
reputation: i32,
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ fn test_once() {
|
||||
// If we generate 2, adjust a random reputation.
|
||||
2 => {
|
||||
if let Some(id) = known_nodes.iter().choose(&mut rng) {
|
||||
let val = Uniform::new_inclusive(i32::min_value(), i32::max_value())
|
||||
let val = Uniform::new_inclusive(i32::min_value(), i32::MAX)
|
||||
.sample(&mut rng);
|
||||
peerset_handle.report_peer(id.clone(), ReputationChange::new(val, ""));
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ trait ChainBackend<Client, Block: BlockT>: Send + Sync + 'static
|
||||
// FIXME <2329>: Database seems to limit the block number to u32 for no reason
|
||||
let block_num: u32 = num_or_hex.try_into().map_err(|_| {
|
||||
Error::from(format!(
|
||||
"`{:?}` > u32::max_value(), the max block number is u32.",
|
||||
"`{:?}` > u32::MAX, the max block number is u32.",
|
||||
num_or_hex
|
||||
))
|
||||
})?;
|
||||
|
||||
@@ -236,7 +236,7 @@ impl<B: BlockT> Speedometer<B> {
|
||||
// algebraic approach and we stay within the realm of integers.
|
||||
let one_thousand = NumberFor::<B>::from(1_000u32);
|
||||
let elapsed = NumberFor::<B>::from(
|
||||
<u32 as TryFrom<_>>::try_from(elapsed_ms).unwrap_or(u32::max_value())
|
||||
<u32 as TryFrom<_>>::try_from(elapsed_ms).unwrap_or(u32::MAX)
|
||||
);
|
||||
|
||||
let speed = diff.saturating_mul(one_thousand).checked_div(&elapsed)
|
||||
|
||||
@@ -1547,7 +1547,7 @@ fn doesnt_import_blocks_that_revert_finality() {
|
||||
cache_size: 1024,
|
||||
},
|
||||
},
|
||||
u64::max_value(),
|
||||
u64::MAX,
|
||||
).unwrap());
|
||||
|
||||
let mut client = TestClientBuilder::with_backend(backend).build();
|
||||
@@ -1751,7 +1751,7 @@ fn returns_status_for_pruned_blocks() {
|
||||
cache_size: 1024,
|
||||
},
|
||||
},
|
||||
u64::max_value(),
|
||||
u64::MAX,
|
||||
).unwrap());
|
||||
|
||||
let mut client = TestClientBuilder::with_backend(backend).build();
|
||||
|
||||
@@ -659,7 +659,7 @@ mod tests {
|
||||
bytes: 1,
|
||||
hash: 5,
|
||||
priority: 1,
|
||||
valid_till: u64::max_value(), // use the max_value() here for testing.
|
||||
valid_till: u64::MAX, // use the max here for testing.
|
||||
requires: vec![tx1.provides[0].clone()],
|
||||
provides: vec![],
|
||||
propagate: true,
|
||||
@@ -692,7 +692,7 @@ mod tests {
|
||||
bytes: 1,
|
||||
hash: 5,
|
||||
priority: 1,
|
||||
valid_till: u64::max_value(), // use the max_value() here for testing.
|
||||
valid_till: u64::MAX, // use the max here for testing.
|
||||
requires: vec![],
|
||||
provides: vec![],
|
||||
propagate: true,
|
||||
|
||||
Reference in New Issue
Block a user