diff --git a/substrate/client/network/src/lib.rs b/substrate/client/network/src/lib.rs index 1816a21f97..05c8a1dc86 100644 --- a/substrate/client/network/src/lib.rs +++ b/substrate/client/network/src/lib.rs @@ -170,7 +170,6 @@ mod behaviour; mod chain; -mod legacy_proto; mod debug_info; mod discovery; mod on_demand_layer; diff --git a/substrate/client/network/src/protocol.rs b/substrate/client/network/src/protocol.rs index c8a4fadbff..88bc1ede52 100644 --- a/substrate/client/network/src/protocol.rs +++ b/substrate/client/network/src/protocol.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use crate::{DiscoveryNetBehaviour, config::ProtocolId}; -use crate::legacy_proto::{LegacyProto, LegacyProtoOut}; +use legacy_proto::{LegacyProto, LegacyProtoOut}; use crate::utils::interval; use bytes::BytesMut; use futures::prelude::*; @@ -55,7 +55,9 @@ use client_api::{FetchChecker, ChangesProof, StorageProof}; use crate::error; use util::LruHashSet; +mod legacy_proto; mod util; + pub mod consensus_gossip; pub mod message; pub mod event; diff --git a/substrate/client/network/src/legacy_proto/mod.rs b/substrate/client/network/src/protocol/legacy_proto.rs similarity index 72% rename from substrate/client/network/src/legacy_proto/mod.rs rename to substrate/client/network/src/protocol/legacy_proto.rs index bbe795528b..eee30117d9 100644 --- a/substrate/client/network/src/legacy_proto/mod.rs +++ b/substrate/client/network/src/protocol/legacy_proto.rs @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . +//! Implementation of libp2p's `NetworkBehaviour` trait that opens a single substream with the +//! remote and then allows any communication with them. +//! +//! The `Protocol` struct uses `LegacyProto` in order to open substreams with the rest of the +//! network, then performs the Substrate protocol handling on top. + pub use self::behaviour::{LegacyProto, LegacyProtoOut}; mod behaviour; diff --git a/substrate/client/network/src/legacy_proto/behaviour.rs b/substrate/client/network/src/protocol/legacy_proto/behaviour.rs similarity index 99% rename from substrate/client/network/src/legacy_proto/behaviour.rs rename to substrate/client/network/src/protocol/legacy_proto/behaviour.rs index f890219158..ed3ea8af4d 100644 --- a/substrate/client/network/src/legacy_proto/behaviour.rs +++ b/substrate/client/network/src/protocol/legacy_proto/behaviour.rs @@ -15,8 +15,8 @@ // along with Substrate. If not, see . use crate::{DiscoveryNetBehaviour, config::ProtocolId}; -use crate::legacy_proto::handler::{CustomProtoHandlerProto, CustomProtoHandlerOut, CustomProtoHandlerIn}; -use crate::legacy_proto::upgrade::RegisteredProtocol; +use crate::protocol::legacy_proto::handler::{CustomProtoHandlerProto, CustomProtoHandlerOut, CustomProtoHandlerIn}; +use crate::protocol::legacy_proto::upgrade::RegisteredProtocol; use bytes::BytesMut; use fnv::FnvHashMap; use futures::prelude::*; diff --git a/substrate/client/network/src/legacy_proto/handler.rs b/substrate/client/network/src/protocol/legacy_proto/handler.rs similarity index 99% rename from substrate/client/network/src/legacy_proto/handler.rs rename to substrate/client/network/src/protocol/legacy_proto/handler.rs index 7bdbe4a31f..cbd0385734 100644 --- a/substrate/client/network/src/legacy_proto/handler.rs +++ b/substrate/client/network/src/protocol/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::legacy_proto::upgrade::{RegisteredProtocol, RegisteredProtocolEvent, RegisteredProtocolSubstream}; +use super::upgrade::{RegisteredProtocol, RegisteredProtocolEvent, RegisteredProtocolSubstream}; use bytes::BytesMut; use futures::prelude::*; use futures03::{compat::Compat, TryFutureExt as _}; diff --git a/substrate/client/network/src/legacy_proto/tests.rs b/substrate/client/network/src/protocol/legacy_proto/tests.rs similarity index 99% rename from substrate/client/network/src/legacy_proto/tests.rs rename to substrate/client/network/src/protocol/legacy_proto/tests.rs index dc6d40eb04..08c3a47c0e 100644 --- a/substrate/client/network/src/legacy_proto/tests.rs +++ b/substrate/client/network/src/protocol/legacy_proto/tests.rs @@ -26,7 +26,7 @@ use libp2p::{PeerId, Multiaddr, Transport}; use rand::seq::SliceRandom; use std::{io, time::Duration, time::Instant}; use crate::message::Message; -use crate::legacy_proto::{LegacyProto, LegacyProtoOut}; +use crate::protocol::legacy_proto::{LegacyProto, LegacyProtoOut}; use test_client::runtime::Block; /// Builds two nodes that have each other as bootstrap nodes. diff --git a/substrate/client/network/src/legacy_proto/upgrade.rs b/substrate/client/network/src/protocol/legacy_proto/upgrade.rs similarity index 100% rename from substrate/client/network/src/legacy_proto/upgrade.rs rename to substrate/client/network/src/protocol/legacy_proto/upgrade.rs