diff --git a/substrate/core/network/src/custom_proto/behaviour.rs b/substrate/core/network/src/legacy_proto/behaviour.rs
similarity index 97%
rename from substrate/core/network/src/custom_proto/behaviour.rs
rename to substrate/core/network/src/legacy_proto/behaviour.rs
index 1cfa16ea6b..790c1d158d 100644
--- a/substrate/core/network/src/custom_proto/behaviour.rs
+++ b/substrate/core/network/src/legacy_proto/behaviour.rs
@@ -15,8 +15,8 @@
// along with Substrate. If not, see .
use crate::{DiscoveryNetBehaviour, config::ProtocolId};
-use crate::custom_proto::handler::{CustomProtoHandlerProto, CustomProtoHandlerOut, CustomProtoHandlerIn};
-use crate::custom_proto::upgrade::RegisteredProtocol;
+use crate::legacy_proto::handler::{CustomProtoHandlerProto, CustomProtoHandlerOut, CustomProtoHandlerIn};
+use crate::legacy_proto::upgrade::RegisteredProtocol;
use crate::protocol::message::Message;
use fnv::FnvHashMap;
use futures::prelude::*;
@@ -34,7 +34,7 @@ use tokio_io::{AsyncRead, AsyncWrite};
///
/// ## How it works
///
-/// The role of the `CustomProto` is to synchronize the following components:
+/// The role of the `LegacyProto` is to synchronize the following components:
///
/// - The libp2p swarm that opens new connections and reports disconnects.
/// - The connection handler (see `handler.rs`) that handles individual connections.
@@ -60,7 +60,7 @@ use tokio_io::{AsyncRead, AsyncWrite};
/// Note that this "banning" system is not an actual ban. If a "banned" node tries to connect to
/// us, we accept the connection. The "banning" system is only about delaying dialing attempts.
///
-pub struct CustomProto {
+pub struct LegacyProto {
/// List of protocols to open with peers. Never modified.
protocol: RegisteredProtocol,
@@ -79,7 +79,7 @@ pub struct CustomProto {
next_incoming_index: peerset::IncomingIndex,
/// Events to produce from `poll()`.
- events: SmallVec<[NetworkBehaviourAction, CustomProtoOut>; 4]>,
+ events: SmallVec<[NetworkBehaviourAction, LegacyProtoOut>; 4]>,
/// Marker to pin the generics.
marker: PhantomData,
@@ -186,9 +186,9 @@ struct IncomingPeer {
incoming_id: peerset::IncomingIndex,
}
-/// Event that can be emitted by the `CustomProto`.
+/// Event that can be emitted by the `LegacyProto`.
#[derive(Debug)]
-pub enum CustomProtoOut {
+pub enum LegacyProtoOut {
/// Opened a custom protocol with the remote.
CustomProtocolOpen {
/// Version of the protocol that has been opened.
@@ -225,7 +225,7 @@ pub enum CustomProtoOut {
},
}
-impl CustomProto {
+impl LegacyProto {
/// Creates a `CustomProtos`.
pub fn new(
protocol: impl Into,
@@ -234,7 +234,7 @@ impl CustomProto {
) -> Self {
let protocol = RegisteredProtocol::new(protocol, versions);
- CustomProto {
+ LegacyProto {
protocol,
peerset,
peers: FnvHashMap::default(),
@@ -606,7 +606,7 @@ impl CustomProto {
}
}
-impl DiscoveryNetBehaviour for CustomProto {
+impl DiscoveryNetBehaviour for LegacyProto {
fn add_discovered_nodes(&mut self, peer_ids: impl Iterator- ) {
self.peerset.discovered(peer_ids.into_iter().map(|peer_id| {
debug!(target: "sub-libp2p", "PSM <= Discovered({:?})", peer_id);
@@ -615,13 +615,13 @@ impl DiscoveryNetBehaviour for CustomProto
}
}
-impl NetworkBehaviour for CustomProto
+impl NetworkBehaviour for LegacyProto
where
TSubstream: AsyncRead + AsyncWrite,
B: BlockT,
{
type ProtocolsHandler = CustomProtoHandlerProto;
- type OutEvent = CustomProtoOut;
+ type OutEvent = LegacyProtoOut;
fn new_handler(&mut self) -> Self::ProtocolsHandler {
CustomProtoHandlerProto::new(self.protocol.clone())
@@ -714,7 +714,7 @@ where
}
if open {
debug!(target: "sub-libp2p", "External API <= Closed({:?})", peer_id);
- let event = CustomProtoOut::CustomProtocolClosed {
+ let event = LegacyProtoOut::CustomProtocolClosed {
peer_id: peer_id.clone(),
reason: "Disconnected by libp2p".into(),
};
@@ -731,7 +731,7 @@ where
self.peers.insert(peer_id.clone(), PeerState::Banned { until: timer_deadline });
if open {
debug!(target: "sub-libp2p", "External API <= Closed({:?})", peer_id);
- let event = CustomProtoOut::CustomProtocolClosed {
+ let event = LegacyProtoOut::CustomProtocolClosed {
peer_id: peer_id.clone(),
reason: "Disconnected by libp2p".into(),
};
@@ -748,7 +748,7 @@ where
if open {
debug!(target: "sub-libp2p", "External API <= Closed({:?})", peer_id);
- let event = CustomProtoOut::CustomProtocolClosed {
+ let event = LegacyProtoOut::CustomProtocolClosed {
peer_id: peer_id.clone(),
reason: "Disconnected by libp2p".into(),
};
@@ -833,7 +833,7 @@ where
};
debug!(target: "sub-libp2p", "External API <= Closed({:?})", source);
- let event = CustomProtoOut::CustomProtocolClosed {
+ let event = LegacyProtoOut::CustomProtocolClosed {
reason,
peer_id: source.clone(),
};
@@ -891,7 +891,7 @@ where
};
debug!(target: "sub-libp2p", "External API <= Open({:?})", source);
- let event = CustomProtoOut::CustomProtocolOpen {
+ let event = LegacyProtoOut::CustomProtocolOpen {
version,
peer_id: source,
endpoint,
@@ -904,7 +904,7 @@ where
debug_assert!(self.is_open(&source));
trace!(target: "sub-libp2p", "Handler({:?}) => Message", source);
trace!(target: "sub-libp2p", "External API <= Message({:?})", source);
- let event = CustomProtoOut::CustomMessage {
+ let event = LegacyProtoOut::CustomMessage {
peer_id: source,
message,
};
@@ -918,7 +918,7 @@ where
trace!(target: "sub-libp2p", "External API <= Clogged({:?})", source);
warn!(target: "sub-libp2p", "Queue of packets to send to {:?} is \
pretty large", source);
- self.events.push(NetworkBehaviourAction::GenerateEvent(CustomProtoOut::Clogged {
+ self.events.push(NetworkBehaviourAction::GenerateEvent(LegacyProtoOut::Clogged {
peer_id: source,
messages,
}));
diff --git a/substrate/core/network/src/custom_proto/handler.rs b/substrate/core/network/src/legacy_proto/handler.rs
similarity index 99%
rename from substrate/core/network/src/custom_proto/handler.rs
rename to substrate/core/network/src/legacy_proto/handler.rs
index 5cdedf4940..3fe88d3cfd 100644
--- a/substrate/core/network/src/custom_proto/handler.rs
+++ b/substrate/core/network/src/legacy_proto/handler.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see .
-use crate::custom_proto::upgrade::{RegisteredProtocol, RegisteredProtocolEvent, RegisteredProtocolSubstream};
+use crate::legacy_proto::upgrade::{RegisteredProtocol, RegisteredProtocolEvent, RegisteredProtocolSubstream};
use crate::protocol::message::Message;
use futures::prelude::*;
use futures03::{compat::Compat, TryFutureExt as _};
diff --git a/substrate/core/network/src/custom_proto/mod.rs b/substrate/core/network/src/legacy_proto/mod.rs
similarity index 93%
rename from substrate/core/network/src/custom_proto/mod.rs
rename to substrate/core/network/src/legacy_proto/mod.rs
index 99f4f0183a..bbe795528b 100644
--- a/substrate/core/network/src/custom_proto/mod.rs
+++ b/substrate/core/network/src/legacy_proto/mod.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see .
-pub use self::behaviour::{CustomProto, CustomProtoOut};
+pub use self::behaviour::{LegacyProto, LegacyProtoOut};
mod behaviour;
mod handler;
diff --git a/substrate/core/network/src/custom_proto/tests.rs b/substrate/core/network/src/legacy_proto/tests.rs
similarity index 92%
rename from substrate/core/network/src/custom_proto/tests.rs
rename to substrate/core/network/src/legacy_proto/tests.rs
index 94456b1a0f..8fd47843df 100644
--- a/substrate/core/network/src/custom_proto/tests.rs
+++ b/substrate/core/network/src/legacy_proto/tests.rs
@@ -26,7 +26,7 @@ use rand::seq::SliceRandom;
use std::{io, time::Duration, time::Instant};
use test_client::runtime::Block;
use crate::message::generic::Message;
-use crate::custom_proto::{CustomProto, CustomProtoOut};
+use crate::legacy_proto::{LegacyProto, LegacyProtoOut};
/// Builds two nodes that have each other as bootstrap nodes.
/// This is to be used only for testing, and a panic will happen if something goes wrong.
@@ -71,7 +71,7 @@ fn build_nodes()
});
let behaviour = CustomProtoWithAddr {
- inner: CustomProto::new(&b"test"[..], &[1], peerset),
+ inner: LegacyProto::new(&b"test"[..], &[1], peerset),
addrs: addrs
.iter()
.enumerate()
@@ -101,12 +101,12 @@ fn build_nodes()
/// Wraps around the `CustomBehaviour` network behaviour, and adds hardcoded node addresses to it.
struct CustomProtoWithAddr {
- inner: CustomProto>,
+ inner: LegacyProto>,
addrs: Vec<(PeerId, Multiaddr)>,
}
impl std::ops::Deref for CustomProtoWithAddr {
- type Target = CustomProto>;
+ type Target = LegacyProto>;
fn deref(&self) -> &Self::Target {
&self.inner
@@ -121,8 +121,8 @@ impl std::ops::DerefMut for CustomProtoWithAddr {
impl NetworkBehaviour for CustomProtoWithAddr {
type ProtocolsHandler =
- > as NetworkBehaviour>::ProtocolsHandler;
- type OutEvent = > as NetworkBehaviour>::OutEvent;
+ > as NetworkBehaviour>::ProtocolsHandler;
+ type OutEvent = > as NetworkBehaviour>::OutEvent;
fn new_handler(&mut self) -> Self::ProtocolsHandler {
self.inner.new_handler()
@@ -205,7 +205,7 @@ fn two_nodes_transfer_lots_of_packets() {
let fut1 = future::poll_fn(move || -> io::Result<_> {
loop {
match try_ready!(service1.poll()) {
- Some(CustomProtoOut::CustomProtocolOpen { peer_id, .. }) => {
+ Some(LegacyProtoOut::CustomProtocolOpen { peer_id, .. }) => {
for n in 0 .. NUM_PACKETS {
service1.send_packet(
&peer_id,
@@ -222,8 +222,8 @@ fn two_nodes_transfer_lots_of_packets() {
let fut2 = future::poll_fn(move || -> io::Result<_> {
loop {
match try_ready!(service2.poll()) {
- Some(CustomProtoOut::CustomProtocolOpen { .. }) => {},
- Some(CustomProtoOut::CustomMessage { message: Message::ChainSpecific(message), .. }) => {
+ Some(LegacyProtoOut::CustomProtocolOpen { .. }) => {},
+ Some(LegacyProtoOut::CustomMessage { message: Message::ChainSpecific(message), .. }) => {
assert_eq!(message.len(), 1);
packet_counter += 1;
if packet_counter == NUM_PACKETS {
@@ -261,7 +261,7 @@ fn basic_two_nodes_requests_in_parallel() {
let fut1 = future::poll_fn(move || -> io::Result<_> {
loop {
match try_ready!(service1.poll()) {
- Some(CustomProtoOut::CustomProtocolOpen { peer_id, .. }) => {
+ Some(LegacyProtoOut::CustomProtocolOpen { peer_id, .. }) => {
for msg in to_send.drain(..) {
service1.send_packet(&peer_id, msg);
}
@@ -274,8 +274,8 @@ fn basic_two_nodes_requests_in_parallel() {
let fut2 = future::poll_fn(move || -> io::Result<_> {
loop {
match try_ready!(service2.poll()) {
- Some(CustomProtoOut::CustomProtocolOpen { .. }) => {},
- Some(CustomProtoOut::CustomMessage { message, .. }) => {
+ Some(LegacyProtoOut::CustomProtocolOpen { .. }) => {},
+ Some(LegacyProtoOut::CustomMessage { message, .. }) => {
let pos = to_receive.iter().position(|m| *m == message).unwrap();
to_receive.remove(pos);
if to_receive.is_empty() {
@@ -313,7 +313,7 @@ fn reconnect_after_disconnect() {
let mut service1_not_ready = false;
match service1.poll().unwrap() {
- Async::Ready(Some(CustomProtoOut::CustomProtocolOpen { .. })) => {
+ Async::Ready(Some(LegacyProtoOut::CustomProtocolOpen { .. })) => {
match service1_state {
ServiceState::NotConnected => {
service1_state = ServiceState::FirstConnec;
@@ -325,7 +325,7 @@ fn reconnect_after_disconnect() {
ServiceState::FirstConnec | ServiceState::ConnectedAgain => panic!(),
}
},
- Async::Ready(Some(CustomProtoOut::CustomProtocolClosed { .. })) => {
+ Async::Ready(Some(LegacyProtoOut::CustomProtocolClosed { .. })) => {
match service1_state {
ServiceState::FirstConnec => service1_state = ServiceState::Disconnected,
ServiceState::ConnectedAgain| ServiceState::NotConnected |
@@ -337,7 +337,7 @@ fn reconnect_after_disconnect() {
}
match service2.poll().unwrap() {
- Async::Ready(Some(CustomProtoOut::CustomProtocolOpen { .. })) => {
+ Async::Ready(Some(LegacyProtoOut::CustomProtocolOpen { .. })) => {
match service2_state {
ServiceState::NotConnected => {
service2_state = ServiceState::FirstConnec;
@@ -349,7 +349,7 @@ fn reconnect_after_disconnect() {
ServiceState::FirstConnec | ServiceState::ConnectedAgain => panic!(),
}
},
- Async::Ready(Some(CustomProtoOut::CustomProtocolClosed { .. })) => {
+ Async::Ready(Some(LegacyProtoOut::CustomProtocolClosed { .. })) => {
match service2_state {
ServiceState::FirstConnec => service2_state = ServiceState::Disconnected,
ServiceState::ConnectedAgain| ServiceState::NotConnected |
diff --git a/substrate/core/network/src/custom_proto/upgrade.rs b/substrate/core/network/src/legacy_proto/upgrade.rs
similarity index 100%
rename from substrate/core/network/src/custom_proto/upgrade.rs
rename to substrate/core/network/src/legacy_proto/upgrade.rs
diff --git a/substrate/core/network/src/lib.rs b/substrate/core/network/src/lib.rs
index bbb1f08556..33f9e5d2eb 100644
--- a/substrate/core/network/src/lib.rs
+++ b/substrate/core/network/src/lib.rs
@@ -170,7 +170,7 @@
mod behaviour;
mod chain;
-mod custom_proto;
+mod legacy_proto;
mod debug_info;
mod discovery;
mod on_demand_layer;
diff --git a/substrate/core/network/src/protocol.rs b/substrate/core/network/src/protocol.rs
index 9d4a537ed2..88252d7786 100644
--- a/substrate/core/network/src/protocol.rs
+++ b/substrate/core/network/src/protocol.rs
@@ -15,7 +15,7 @@
// along with Substrate. If not, see .
use crate::{DiscoveryNetBehaviour, config::ProtocolId};
-use crate::custom_proto::{CustomProto, CustomProtoOut};
+use crate::legacy_proto::{LegacyProto, LegacyProtoOut};
use futures::prelude::*;
use futures03::{StreamExt as _, TryStreamExt as _};
use libp2p::{Multiaddr, PeerId};
@@ -111,7 +111,7 @@ pub struct Protocol, H: ExHashT> {
/// When asked for a proof of finality, we use this struct to build one.
finality_proof_provider: Option>>,
/// Handles opening the unique substream and sending and receiving raw messages.
- behaviour: CustomProto>,
+ behaviour: LegacyProto>,
}
/// A peer that we are connected to
@@ -150,7 +150,7 @@ pub struct PeerInfo {
}
struct LightDispatchIn<'a, B: BlockT> {
- behaviour: &'a mut CustomProto>,
+ behaviour: &'a mut LegacyProto>,
peerset: peerset::PeersetHandle,
}
@@ -281,7 +281,7 @@ pub trait Context {
/// Protocol context.
struct ProtocolContext<'a, B: 'a + BlockT, H: 'a + ExHashT> {
- behaviour: &'a mut CustomProto>,
+ behaviour: &'a mut LegacyProto>,
context_data: &'a mut ContextData,
peerset_handle: &'a peerset::PeersetHandle,
}
@@ -289,7 +289,7 @@ struct ProtocolContext<'a, B: 'a + BlockT, H: 'a + ExHashT> {
impl<'a, B: BlockT + 'a, H: 'a + ExHashT> ProtocolContext<'a, B, H> {
fn new(
context_data: &'a mut ContextData,
- behaviour: &'a mut CustomProto>,
+ behaviour: &'a mut LegacyProto>,
peerset_handle: &'a peerset::PeersetHandle,
) -> Self {
ProtocolContext { context_data, peerset_handle, behaviour }
@@ -363,7 +363,7 @@ impl, H: ExHashT> Protocol {
let sync = ChainSync::new(config.roles, chain.clone(), &info, finality_proof_request_builder);
let (peerset, peerset_handle) = peerset::Peerset::from_config(peerset_config);
let versions = &((MIN_VERSION as u8)..=(CURRENT_VERSION as u8)).collect::>();
- let behaviour = CustomProto::new(protocol_id, versions, peerset);
+ let behaviour = LegacyProto::new(protocol_id, versions, peerset);
let protocol = Protocol {
tick_timeout: Box::new(futures_timer::Interval::new(TICK_TIMEOUT).map(|v| Ok::<_, ()>(v)).compat()),
@@ -1479,7 +1479,7 @@ pub enum CustomMessageOutcome {
}
fn send_message(
- behaviour: &mut CustomProto>,
+ behaviour: &mut LegacyProto>,
peers: &mut HashMap>,
who: PeerId,
mut message: Message,
@@ -1500,7 +1500,7 @@ fn send_message(
impl, H: ExHashT> NetworkBehaviour for
Protocol {
- type ProtocolsHandler = > as NetworkBehaviour>::ProtocolsHandler;
+ type ProtocolsHandler = > as NetworkBehaviour>::ProtocolsHandler;
type OutEvent = CustomMessageOutcome;
fn new_handler(&mut self) -> Self::ProtocolsHandler {
@@ -1568,7 +1568,7 @@ Protocol {
};
let outcome = match event {
- CustomProtoOut::CustomProtocolOpen { peer_id, version, .. } => {
+ LegacyProtoOut::CustomProtocolOpen { peer_id, version, .. } => {
debug_assert!(
version <= CURRENT_VERSION as u8
&& version >= MIN_VERSION as u8
@@ -1576,13 +1576,13 @@ Protocol {
self.on_peer_connected(peer_id);
CustomMessageOutcome::None
}
- CustomProtoOut::CustomProtocolClosed { peer_id, .. } => {
+ LegacyProtoOut::CustomProtocolClosed { peer_id, .. } => {
self.on_peer_disconnected(peer_id);
CustomMessageOutcome::None
},
- CustomProtoOut::CustomMessage { peer_id, message } =>
+ LegacyProtoOut::CustomMessage { peer_id, message } =>
self.on_custom_message(peer_id, message),
- CustomProtoOut::Clogged { peer_id, messages } => {
+ LegacyProtoOut::Clogged { peer_id, messages } => {
debug!(target: "sync", "{} clogging messages:", messages.len());
for msg in messages.into_iter().take(5) {
debug!(target: "sync", "{:?}", msg);