mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 10:31:04 +00:00
@@ -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()
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user