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:
Aaro Altonen
2023-03-14 14:06:40 +02:00
committed by GitHub
parent 5d718e45c1
commit 9ced14e2de
85 changed files with 1411 additions and 1434 deletions
+14 -12
View File
@@ -16,7 +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::config;
use crate::{
config::{self, NonReservedPeerMode},
error,
types::ProtocolName,
};
use bytes::Bytes;
use codec::{DecodeAll, Encode};
@@ -29,27 +33,25 @@ use libp2p::{
Multiaddr, PeerId,
};
use log::{debug, error, warn};
use message::{generic::Message as GenericMessage, Message};
use notifications::{Notifications, NotificationsOut};
use sc_network_common::{
config::NonReservedPeerMode,
error,
protocol::{role::Roles, ProtocolName},
sync::message::BlockAnnouncesHandshake,
};
use sc_network_common::{role::Roles, sync::message::BlockAnnouncesHandshake};
use sp_runtime::traits::Block as BlockT;
use std::{
collections::{HashMap, HashSet, VecDeque},
iter,
task::Poll,
};
use message::{generic::Message as GenericMessage, Message};
use notifications::{Notifications, NotificationsOut};
pub use notifications::{NotificationsSink, NotifsHandlerError, Ready};
mod notifications;
pub mod message;
pub use notifications::{NotificationsSink, NotifsHandlerError, Ready};
/// Maximum size used for notifications in the block announce and transaction protocols.
// Must be equal to `max(MAX_BLOCK_ANNOUNCE_SIZE, MAX_TRANSACTIONS_SIZE)`.
pub(crate) const BLOCK_ANNOUNCES_TRANSACTIONS_SUBSTREAM_SIZE: u64 = 16 * 1024 * 1024;
@@ -93,7 +95,7 @@ impl<B: BlockT> Protocol<B> {
pub fn new(
roles: Roles,
network_config: &config::NetworkConfiguration,
block_announces_protocol: sc_network_common::config::NonDefaultSetConfig,
block_announces_protocol: config::NonDefaultSetConfig,
) -> error::Result<(Self, sc_peerset::PeersetHandle, Vec<(PeerId, Multiaddr)>)> {
let mut known_addresses = Vec::new();