mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 08:47:57 +00:00
Move code from sc-network-common back to sc-network (#13592)
* Move service tests to `client/network/tests` These tests depend on `sc-network` and `sc-network-sync` so they should live outside the crate. * Move some configs from `sc-network-common` to `sc-network` * Move `NetworkService` traits to `sc-network` * Move request-responses to `sc-network` * Remove more stuff * Remove rest of configs from `sc-network-common` to `sc-network` * Remove more stuff * Fix warnings * Update client/network/src/request_responses.rs Co-authored-by: Dmitry Markin <dmitry@markin.tech> * Fix cargo doc --------- Co-authored-by: Dmitry Markin <dmitry@markin.tech>
This commit is contained in:
@@ -61,7 +61,7 @@ pub mod generic {
|
||||
use sc_client_api::StorageProof;
|
||||
use sc_network_common::{
|
||||
message::RequestId,
|
||||
protocol::role::Roles,
|
||||
role::Roles,
|
||||
sync::message::{
|
||||
generic::{BlockRequest, BlockResponse},
|
||||
BlockAnnounce,
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::protocol::notifications::handler::{
|
||||
self, NotificationsSink, NotifsHandlerIn, NotifsHandlerOut, NotifsHandlerProto,
|
||||
use crate::{
|
||||
protocol::notifications::handler::{
|
||||
self, NotificationsSink, NotifsHandlerIn, NotifsHandlerOut, NotifsHandlerProto,
|
||||
},
|
||||
types::ProtocolName,
|
||||
};
|
||||
|
||||
use bytes::BytesMut;
|
||||
@@ -35,7 +38,6 @@ use libp2p::{
|
||||
use log::{error, trace, warn};
|
||||
use parking_lot::RwLock;
|
||||
use rand::distributions::{Distribution as _, Uniform};
|
||||
use sc_network_common::protocol::ProtocolName;
|
||||
use sc_peerset::DropReason;
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
|
||||
@@ -57,9 +57,12 @@
|
||||
//! It is illegal to send a [`NotifsHandlerIn::Open`] before a previously-emitted
|
||||
//! [`NotifsHandlerIn::Open`] has gotten an answer.
|
||||
|
||||
use crate::protocol::notifications::upgrade::{
|
||||
NotificationsIn, NotificationsInSubstream, NotificationsOut, NotificationsOutSubstream,
|
||||
UpgradeCollec,
|
||||
use crate::{
|
||||
protocol::notifications::upgrade::{
|
||||
NotificationsIn, NotificationsInSubstream, NotificationsOut, NotificationsOutSubstream,
|
||||
UpgradeCollec,
|
||||
},
|
||||
types::ProtocolName,
|
||||
};
|
||||
|
||||
use bytes::BytesMut;
|
||||
@@ -77,7 +80,6 @@ use libp2p::{
|
||||
};
|
||||
use log::error;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use sc_network_common::protocol::ProtocolName;
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
mem,
|
||||
@@ -945,8 +947,9 @@ pub mod tests {
|
||||
Poll::Ready(Some(NotificationsSinkMessage::Notification { message })) =>
|
||||
Poll::Ready(Some(message)),
|
||||
Poll::Pending => Poll::Ready(None),
|
||||
Poll::Ready(Some(NotificationsSinkMessage::ForceClose)) | Poll::Ready(None) =>
|
||||
panic!("sink closed"),
|
||||
Poll::Ready(Some(NotificationsSinkMessage::ForceClose)) | Poll::Ready(None) => {
|
||||
panic!("sink closed")
|
||||
},
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ impl<T: Future<Output = Result<O, E>>, O, E> Future for FutWithUsize<T> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::types::ProtocolName as ProtoName;
|
||||
use libp2p::core::upgrade::{ProtocolName, UpgradeInfo};
|
||||
use sc_network_common::protocol::ProtocolName as ProtoName;
|
||||
|
||||
// TODO: move to mocks
|
||||
mockall::mock! {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use asynchronous_codec::Framed;
|
||||
/// Notifications protocol.
|
||||
///
|
||||
/// The Substrate notifications protocol consists in the following:
|
||||
@@ -35,11 +34,15 @@ use asynchronous_codec::Framed;
|
||||
///
|
||||
/// Notification substreams are unidirectional. If A opens a substream with B, then B is
|
||||
/// encouraged but not required to open a substream to A as well.
|
||||
use crate::types::ProtocolName;
|
||||
|
||||
use asynchronous_codec::Framed;
|
||||
use bytes::BytesMut;
|
||||
use futures::prelude::*;
|
||||
use libp2p::core::{upgrade, InboundUpgrade, OutboundUpgrade, UpgradeInfo};
|
||||
use log::{error, warn};
|
||||
use sc_network_common::protocol::ProtocolName;
|
||||
use unsigned_varint::codec::UviBytes;
|
||||
|
||||
use std::{
|
||||
convert::Infallible,
|
||||
io, mem,
|
||||
@@ -47,7 +50,6 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
vec,
|
||||
};
|
||||
use unsigned_varint::codec::UviBytes;
|
||||
|
||||
/// Maximum allowed size of the two handshake messages, in bytes.
|
||||
const MAX_HANDSHAKE_SIZE: usize = 1024;
|
||||
|
||||
Reference in New Issue
Block a user