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:
@@ -251,19 +251,15 @@ pub enum SyncMode {
|
||||
Warp,
|
||||
}
|
||||
|
||||
impl Into<sc_network_common::config::SyncMode> for SyncMode {
|
||||
fn into(self) -> sc_network_common::config::SyncMode {
|
||||
impl Into<sc_network::config::SyncMode> for SyncMode {
|
||||
fn into(self) -> sc_network::config::SyncMode {
|
||||
match self {
|
||||
SyncMode::Full => sc_network_common::config::SyncMode::Full,
|
||||
SyncMode::Fast => sc_network_common::config::SyncMode::Fast {
|
||||
skip_proofs: false,
|
||||
storage_chain_mode: false,
|
||||
},
|
||||
SyncMode::FastUnsafe => sc_network_common::config::SyncMode::Fast {
|
||||
skip_proofs: true,
|
||||
storage_chain_mode: false,
|
||||
},
|
||||
SyncMode::Warp => sc_network_common::config::SyncMode::Warp,
|
||||
SyncMode::Full => sc_network::config::SyncMode::Full,
|
||||
SyncMode::Fast =>
|
||||
sc_network::config::SyncMode::Fast { skip_proofs: false, storage_chain_mode: false },
|
||||
SyncMode::FastUnsafe =>
|
||||
sc_network::config::SyncMode::Fast { skip_proofs: true, storage_chain_mode: false },
|
||||
SyncMode::Warp => sc_network::config::SyncMode::Warp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,12 @@
|
||||
|
||||
use crate::{arg_enums::SyncMode, params::node_key_params::NodeKeyParams};
|
||||
use clap::Args;
|
||||
use sc_network::{config::NetworkConfiguration, multiaddr::Protocol};
|
||||
use sc_network_common::config::{NodeKeyConfig, NonReservedPeerMode, SetConfig, TransportConfig};
|
||||
use sc_network::{
|
||||
config::{
|
||||
NetworkConfiguration, NodeKeyConfig, NonReservedPeerMode, SetConfig, TransportConfig,
|
||||
},
|
||||
multiaddr::Protocol,
|
||||
};
|
||||
use sc_service::{
|
||||
config::{Multiaddr, MultiaddrWithPeerId},
|
||||
ChainSpec, ChainType,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use clap::Args;
|
||||
use sc_network_common::config::{identity::ed25519, NodeKeyConfig};
|
||||
use sc_network::config::{identity::ed25519, NodeKeyConfig};
|
||||
use sp_core::H256;
|
||||
use std::{path::PathBuf, str::FromStr};
|
||||
|
||||
@@ -92,7 +92,7 @@ impl NodeKeyParams {
|
||||
let secret = if let Some(node_key) = self.node_key.as_ref() {
|
||||
parse_ed25519_secret(node_key)?
|
||||
} else {
|
||||
sc_network_common::config::Secret::File(
|
||||
sc_network::config::Secret::File(
|
||||
self.node_key_file
|
||||
.clone()
|
||||
.unwrap_or_else(|| net_config_dir.join(NODE_KEY_ED25519_FILE)),
|
||||
@@ -111,10 +111,10 @@ fn invalid_node_key(e: impl std::fmt::Display) -> error::Error {
|
||||
}
|
||||
|
||||
/// Parse a Ed25519 secret key from a hex string into a `sc_network::Secret`.
|
||||
fn parse_ed25519_secret(hex: &str) -> error::Result<sc_network_common::config::Ed25519Secret> {
|
||||
fn parse_ed25519_secret(hex: &str) -> error::Result<sc_network::config::Ed25519Secret> {
|
||||
H256::from_str(hex).map_err(invalid_node_key).and_then(|bytes| {
|
||||
ed25519::SecretKey::from_bytes(bytes)
|
||||
.map(sc_network_common::config::Secret::Input)
|
||||
.map(sc_network::config::Secret::Input)
|
||||
.map_err(invalid_node_key)
|
||||
})
|
||||
}
|
||||
@@ -123,7 +123,7 @@ fn parse_ed25519_secret(hex: &str) -> error::Result<sc_network_common::config::E
|
||||
mod tests {
|
||||
use super::*;
|
||||
use clap::ValueEnum;
|
||||
use sc_network_common::config::identity::{ed25519, Keypair};
|
||||
use sc_network::config::identity::{ed25519, Keypair};
|
||||
use std::fs;
|
||||
|
||||
#[test]
|
||||
@@ -140,7 +140,7 @@ mod tests {
|
||||
node_key_file: None,
|
||||
};
|
||||
params.node_key(net_config_dir).and_then(|c| match c {
|
||||
NodeKeyConfig::Ed25519(sc_network_common::config::Secret::Input(ref ski))
|
||||
NodeKeyConfig::Ed25519(sc_network::config::Secret::Input(ref ski))
|
||||
if node_key_type == NodeKeyType::Ed25519 && &sk[..] == ski.as_ref() =>
|
||||
Ok(()),
|
||||
_ => Err(error::Error::Input("Unexpected node key config".into())),
|
||||
@@ -200,7 +200,7 @@ mod tests {
|
||||
let dir = PathBuf::from(net_config_dir.clone());
|
||||
let typ = params.node_key_type;
|
||||
params.node_key(net_config_dir).and_then(move |c| match c {
|
||||
NodeKeyConfig::Ed25519(sc_network_common::config::Secret::File(ref f))
|
||||
NodeKeyConfig::Ed25519(sc_network::config::Secret::File(ref f))
|
||||
if typ == NodeKeyType::Ed25519 && f == &dir.join(NODE_KEY_ED25519_FILE) =>
|
||||
Ok(()),
|
||||
_ => Err(error::Error::Input("Unexpected node key config".into())),
|
||||
|
||||
Reference in New Issue
Block a user