From 80422680aebc6318e09e77cede62bc1ddfc00035 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 29 Jul 2022 11:27:17 +0200 Subject: [PATCH 1/3] Remove unused fallback protocol names system --- src/libp2p/collection.rs | 7 ------- src/network/service.rs | 3 --- 2 files changed, 10 deletions(-) diff --git a/src/libp2p/collection.rs b/src/libp2p/collection.rs index df418f936e..aea4e47425 100644 --- a/src/libp2p/collection.rs +++ b/src/libp2p/collection.rs @@ -105,12 +105,6 @@ pub struct NotificationProtocolConfig { /// Name of the protocol negotiated on the wire. pub protocol_name: String, - /// Optional alternative names for this protocol. Can represent different versions. - /// - /// Negotiated in order in which they are passed. - // TODO: presently unused - pub fallback_protocol_names: Vec, - /// Maximum size, in bytes, of the handshake that can be received. pub max_handshake_size: usize, @@ -1676,7 +1670,6 @@ pub enum Event { /// If `Ok`, it is now possible to send notifications on this substream. /// If `Err`, the substream no longer exists and the [`SubstreamId`] becomes invalid. NotificationsOutResult { - // TODO: what if fallback? substream_id: SubstreamId, /// If `Ok`, contains the handshake sent back by the remote. Its interpretation is out of /// scope of this module. diff --git a/src/network/service.rs b/src/network/service.rs index 1ed5b9542e..1aa2d71881 100644 --- a/src/network/service.rs +++ b/src/network/service.rs @@ -256,13 +256,11 @@ where .flat_map(|chain| { iter::once(peers::NotificationProtocolConfig { protocol_name: format!("/{}/block-announces/1", chain.protocol_id), - fallback_protocol_names: Vec::new(), max_handshake_size: 1024 * 1024, // TODO: arbitrary max_notification_size: 1024 * 1024, }) .chain(iter::once(peers::NotificationProtocolConfig { protocol_name: format!("/{}/transactions/1", chain.protocol_id), - fallback_protocol_names: Vec::new(), max_handshake_size: 4, max_notification_size: 16 * 1024 * 1024, })) @@ -273,7 +271,6 @@ where // comprehensible. iter::once(peers::NotificationProtocolConfig { protocol_name: "/paritytech/grandpa/1".to_string(), - fallback_protocol_names: Vec::new(), max_handshake_size: 4, max_notification_size: 1024 * 1024, }) From a0d56ec713e520265296dd1e148ab18652b7fa33 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 29 Jul 2022 11:34:35 +0200 Subject: [PATCH 2/3] Fix build --- src/libp2p/collection/multi_stream.rs | 16 ++++------------ src/libp2p/collection/single_stream.rs | 17 ++++------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/libp2p/collection/multi_stream.rs b/src/libp2p/collection/multi_stream.rs index 326e8b3a26..3a117fd032 100644 --- a/src/libp2p/collection/multi_stream.rs +++ b/src/libp2p/collection/multi_stream.rs @@ -95,18 +95,10 @@ where established: established::MultiStream::new(established::Config { notifications_protocols: notification_protocols .iter() - .flat_map(|net| { - let max_handshake_size = net.config.max_handshake_size; - let max_notification_size = net.config.max_notification_size; - iter::once(&net.config.protocol_name) - .chain(net.config.fallback_protocol_names.iter()) - .map(move |name| { - established::ConfigNotifications { - name: name.clone(), // TODO: cloning :-/ - max_handshake_size, - max_notification_size, - } - }) + .map(|net| established::ConfigNotifications { + name: net.config.protocol_name.clone(), // TODO: clone :-/ + max_handshake_size: net.config.max_handshake_size, + max_notification_size: net.config.max_notification_size, }) .collect(), request_protocols: request_response_protocols.to_vec(), // TODO: overhead diff --git a/src/libp2p/collection/single_stream.rs b/src/libp2p/collection/single_stream.rs index 44bb8089e9..46ae14a547 100644 --- a/src/libp2p/collection/single_stream.rs +++ b/src/libp2p/collection/single_stream.rs @@ -680,19 +680,10 @@ where established: connection.into_connection(established::Config { notifications_protocols: notification_protocols .iter() - .flat_map(|net| { - let max_handshake_size = net.config.max_handshake_size; - let max_notification_size = - net.config.max_notification_size; - iter::once(&net.config.protocol_name) - .chain(net.config.fallback_protocol_names.iter()) - .map(move |name| { - established::ConfigNotifications { - name: name.clone(), // TODO: cloning :-/ - max_handshake_size, - max_notification_size, - } - }) + .map(|net| established::ConfigNotifications { + name: net.config.protocol_name.clone(), // TODO: clone :-/ + max_handshake_size: net.config.max_handshake_size, + max_notification_size: net.config.max_notification_size, }) .collect(), request_protocols: request_response_protocols.to_vec(), // TODO: overhead From 8b775b405723ac640c890559f2f2594b01753fd1 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 29 Jul 2022 11:37:34 +0200 Subject: [PATCH 3/3] Remove unused import --- src/libp2p/collection/single_stream.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libp2p/collection/single_stream.rs b/src/libp2p/collection/single_stream.rs index 46ae14a547..a1793a0611 100644 --- a/src/libp2p/collection/single_stream.rs +++ b/src/libp2p/collection/single_stream.rs @@ -29,7 +29,7 @@ use super::{ use alloc::{collections::VecDeque, string::ToString as _, sync::Arc}; use core::{ - iter, mem, + mem, ops::{Add, Sub}, time::Duration, };