Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused fallback protocol names system #2569

Merged
merged 4 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/libp2p/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

/// Maximum size, in bytes, of the handshake that can be received.
pub max_handshake_size: usize,

Expand Down Expand Up @@ -1676,7 +1670,6 @@ pub enum Event<TConn> {
/// 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.
Expand Down
16 changes: 4 additions & 12 deletions src/libp2p/collection/multi_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 5 additions & 14 deletions src/libp2p/collection/single_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/network/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}))
Expand All @@ -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,
})
Expand Down