mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 16:57:58 +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:
@@ -28,23 +28,13 @@
|
||||
//! the network, or whenever a block has been successfully verified, call the appropriate method in
|
||||
//! order to update it.
|
||||
|
||||
pub mod block_request_handler;
|
||||
pub mod blocks;
|
||||
pub mod engine;
|
||||
pub mod mock;
|
||||
mod schema;
|
||||
pub mod service;
|
||||
pub mod state;
|
||||
pub mod state_request_handler;
|
||||
pub mod warp;
|
||||
pub mod warp_request_handler;
|
||||
|
||||
use crate::{
|
||||
blocks::BlockCollection,
|
||||
schema::v1::{StateRequest, StateResponse},
|
||||
state::StateSync,
|
||||
warp::{WarpProofImportResult, WarpSync},
|
||||
};
|
||||
|
||||
use codec::{Decode, DecodeAll, Encode};
|
||||
use extra_requests::ExtraRequests;
|
||||
use futures::{
|
||||
@@ -52,18 +42,22 @@ use futures::{
|
||||
};
|
||||
use libp2p::{request_response::OutboundFailure, PeerId};
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64};
|
||||
use prost::Message;
|
||||
|
||||
use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64};
|
||||
use sc_client_api::{BlockBackend, ProofProvider};
|
||||
use sc_consensus::{
|
||||
import_queue::ImportQueueService, BlockImportError, BlockImportStatus, IncomingBlock,
|
||||
};
|
||||
use sc_network_common::{
|
||||
use sc_network::{
|
||||
config::{
|
||||
NonDefaultSetConfig, NonReservedPeerMode, NotificationHandshake, ProtocolId, SetConfig,
|
||||
},
|
||||
protocol::{role::Roles, ProtocolName},
|
||||
request_responses::{IfDisconnected, RequestFailure},
|
||||
types::ProtocolName,
|
||||
};
|
||||
use sc_network_common::{
|
||||
role::Roles,
|
||||
sync::{
|
||||
message::{
|
||||
BlockAnnounce, BlockAnnouncesHandshake, BlockAttributes, BlockData, BlockRequest,
|
||||
@@ -76,7 +70,6 @@ use sc_network_common::{
|
||||
SyncState, SyncStatus,
|
||||
},
|
||||
};
|
||||
pub use service::chain_sync::SyncingService;
|
||||
use sp_arithmetic::traits::Saturating;
|
||||
use sp_blockchain::{Error as ClientError, HeaderBackend, HeaderMetadata};
|
||||
use sp_consensus::{
|
||||
@@ -90,6 +83,7 @@ use sp_runtime::{
|
||||
},
|
||||
EncodedJustification, Justifications,
|
||||
};
|
||||
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap, HashSet},
|
||||
iter,
|
||||
@@ -97,9 +91,21 @@ use std::{
|
||||
pin::Pin,
|
||||
sync::Arc,
|
||||
};
|
||||
use warp::TargetBlockImportResult;
|
||||
|
||||
pub use service::chain_sync::SyncingService;
|
||||
|
||||
mod extra_requests;
|
||||
mod schema;
|
||||
|
||||
pub mod block_request_handler;
|
||||
pub mod blocks;
|
||||
pub mod engine;
|
||||
pub mod mock;
|
||||
pub mod service;
|
||||
pub mod state;
|
||||
pub mod state_request_handler;
|
||||
pub mod warp;
|
||||
pub mod warp_request_handler;
|
||||
|
||||
/// Maximum blocks to request in a single packet.
|
||||
const MAX_BLOCKS_TO_REQUEST: usize = 64;
|
||||
@@ -927,9 +933,9 @@ where
|
||||
match warp_sync.import_target_block(
|
||||
blocks.pop().expect("`blocks` len checked above."),
|
||||
) {
|
||||
TargetBlockImportResult::Success =>
|
||||
warp::TargetBlockImportResult::Success =>
|
||||
return Ok(OnBlockData::Continue),
|
||||
TargetBlockImportResult::BadResponse =>
|
||||
warp::TargetBlockImportResult::BadResponse =>
|
||||
return Err(BadPeer(*who, rep::VERIFICATION_FAIL)),
|
||||
}
|
||||
} else if blocks.is_empty() {
|
||||
@@ -3160,7 +3166,7 @@ mod test {
|
||||
use futures::{executor::block_on, future::poll_fn};
|
||||
use sc_block_builder::BlockBuilderProvider;
|
||||
use sc_network_common::{
|
||||
protocol::role::Role,
|
||||
role::Role,
|
||||
sync::message::{BlockData, BlockState, FromBlock},
|
||||
};
|
||||
use sp_blockchain::HeaderBackend;
|
||||
|
||||
Reference in New Issue
Block a user