Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Remove the last bits of unknown_os in the code base #9718

Merged
merged 2 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ sc-tracing = { version = "4.0.0-dev", path = "../tracing" }
chrono = "0.4.10"
serde = "1.0.126"
thiserror = "1.0.21"

[target.'cfg(not(target_os = "unknown"))'.dependencies]
rpassword = "5.0.0"

[dev-dependencies]
Expand Down
9 changes: 1 addition & 8 deletions client/cli/src/params/keystore_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,7 @@ impl KeystoreParams {
/// Returns a vector of remote-urls and the local Keystore configuration
pub fn keystore_config(&self, config_dir: &Path) -> Result<(Option<String>, KeystoreConfig)> {
let password = if self.password_interactive {
#[cfg(not(target_os = "unknown"))]
{
let password = input_keystore_password()?;
Some(SecretString::new(password))
}
#[cfg(target_os = "unknown")]
None
Some(SecretString::new(input_keystore_password()?))
} else if let Some(ref file) = self.password_filename {
let password = fs::read_to_string(file).map_err(|e| format!("{}", e))?;
Some(SecretString::new(password))
Expand Down Expand Up @@ -113,7 +107,6 @@ impl KeystoreParams {
}
}

#[cfg(not(target_os = "unknown"))]
fn input_keystore_password() -> Result<String> {
rpassword::read_password_from_tty(Some("Keystore password: "))
.map_err(|e| format!("{:?}", e).into())
Expand Down
9 changes: 0 additions & 9 deletions client/db/src/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ pub struct LightStorage<Block: BlockT> {
meta: RwLock<Meta<NumberFor<Block>, Block::Hash>>,
cache: Arc<DbCacheSync<Block>>,
header_metadata_cache: Arc<HeaderMetadataCache<Block>>,

#[cfg(not(target_os = "unknown"))]
io_stats: FrozenForDuration<kvdb::IoStats>,
}

Expand Down Expand Up @@ -102,7 +100,6 @@ impl<Block: BlockT> LightStorage<Block> {
meta: RwLock::new(meta),
cache: Arc::new(DbCacheSync(RwLock::new(cache))),
header_metadata_cache,
#[cfg(not(target_os = "unknown"))]
io_stats: FrozenForDuration::new(std::time::Duration::from_secs(1)),
})
}
Expand Down Expand Up @@ -589,7 +586,6 @@ where
Some(self.cache.clone())
}

#[cfg(not(target_os = "unknown"))]
fn usage_info(&self) -> Option<UsageInfo> {
use sc_client_api::{IoInfo, MemoryInfo, MemorySize};

Expand Down Expand Up @@ -619,11 +615,6 @@ where
},
})
}

#[cfg(target_os = "unknown")]
fn usage_info(&self) -> Option<UsageInfo> {
None
}
}

impl<Block> ProvideChtRoots<Block> for LightStorage<Block>
Expand Down
2 changes: 0 additions & 2 deletions client/executor/src/wasm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ impl RuntimeCache {
None => {
let code = runtime_code.fetch_runtime_code().ok_or(WasmError::CodeNotFound)?;

#[cfg(not(target_os = "unknown"))]
let time = std::time::Instant::now();

let result = create_versioned_wasm_runtime(
Expand All @@ -254,7 +253,6 @@ impl RuntimeCache {

match result {
Ok(ref result) => {
#[cfg(not(target_os = "unknown"))]
log::debug!(
target: "wasm-runtime",
"Prepared new runtime version {:?} in {} ms.",
Expand Down
22 changes: 3 additions & 19 deletions client/informant/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,16 @@ impl Default for OutputFormat {
}
}

/// Marker trait for a type that implements `TransactionPool` and `MallocSizeOf` on `not(target_os =
/// "unknown")`.
#[cfg(target_os = "unknown")]
pub trait TransactionPoolAndMaybeMallogSizeOf: TransactionPool {}

/// Marker trait for a type that implements `TransactionPool` and `MallocSizeOf` on `not(target_os =
/// "unknown")`.
#[cfg(not(target_os = "unknown"))]
pub trait TransactionPoolAndMaybeMallogSizeOf: TransactionPool + MallocSizeOf {}

#[cfg(target_os = "unknown")]
impl<T: TransactionPool> TransactionPoolAndMaybeMallogSizeOf for T {}

#[cfg(not(target_os = "unknown"))]
impl<T: TransactionPool + MallocSizeOf> TransactionPoolAndMaybeMallogSizeOf for T {}

/// Builds the informant and returns a `Future` that drives the informant.
pub async fn build<B: BlockT, C>(
pub async fn build<B: BlockT, C, P>(
client: Arc<C>,
network: Arc<NetworkService<B, <B as BlockT>::Hash>>,
pool: Arc<impl TransactionPoolAndMaybeMallogSizeOf>,
pool: Arc<P>,
format: OutputFormat,
) where
C: UsageProvider<B> + HeaderMetadata<B> + BlockchainEvents<B>,
<C as HeaderMetadata<B>>::Error: Display,
P: TransactionPool + MallocSizeOf,
{
let mut display = display::InformantDisplay::new(format.clone());

Expand All @@ -97,7 +82,6 @@ pub async fn build<B: BlockT, C>(
"Usage statistics not displayed as backend does not provide it",
)
}
#[cfg(not(target_os = "unknown"))]
trace!(
target: "usage",
"Subsystems memory [txpool: {} kB]",
Expand Down
21 changes: 1 addition & 20 deletions client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,7 @@ unsigned-varint = { version = "0.6.0", features = [
] }
void = "1.0.2"
zeroize = "1.2.0"

[dependencies.libp2p]
version = "0.39.1"

[target.'cfg(target_os = "unknown")'.dependencies.libp2p]
version = "0.39.1"
default-features = false
features = [
"identify",
"kad",
"mdns",
"mplex",
"noise",
"ping",
"request-response",
"tcp-async-io",
"websocket",
"yamux",
]

libp2p = "0.39.1"

[dev-dependencies]
assert_matches = "1.3"
Expand Down
10 changes: 0 additions & 10 deletions client/network/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ use crate::{config::ProtocolId, utils::LruHashSet};
use futures::prelude::*;
use futures_timer::Delay;
use ip_network::IpNetwork;
#[cfg(not(target_os = "unknown"))]
use libp2p::mdns::{Mdns, MdnsConfig, MdnsEvent};
use libp2p::{
core::{
Expand Down Expand Up @@ -156,9 +155,6 @@ impl DiscoveryConfig {

/// Should MDNS discovery be supported?
pub fn with_mdns(&mut self, value: bool) -> &mut Self {
if value && cfg!(target_os = "unknown") {
log::warn!(target: "sub-libp2p", "mDNS is not available on this platform")
}
self.enable_mdns = value;
self
}
Expand Down Expand Up @@ -234,7 +230,6 @@ impl DiscoveryConfig {
num_connections: 0,
allow_private_ipv4,
discovery_only_if_under_num,
#[cfg(not(target_os = "unknown"))]
mdns: if enable_mdns {
MdnsWrapper::Instantiating(Mdns::new(MdnsConfig::default()).boxed())
} else {
Expand All @@ -257,7 +252,6 @@ pub struct DiscoveryBehaviour {
/// Kademlia requests and answers.
kademlias: HashMap<ProtocolId, Kademlia<MemoryStore>>,
/// Discovers nodes on the local network.
#[cfg(not(target_os = "unknown"))]
mdns: MdnsWrapper,
/// Stream that fires when we need to perform the next random Kademlia query. `None` if
/// random walking is disabled.
Expand Down Expand Up @@ -505,7 +499,6 @@ impl NetworkBehaviour for DiscoveryBehaviour {
list_to_filter.extend(k.addresses_of_peer(peer_id))
}

#[cfg(not(target_os = "unknown"))]
list_to_filter.extend(self.mdns.addresses_of_peer(peer_id));

if !self.allow_private_ipv4 {
Expand Down Expand Up @@ -840,7 +833,6 @@ impl NetworkBehaviour for DiscoveryBehaviour {
}

// Poll mDNS.
#[cfg(not(target_os = "unknown"))]
while let Poll::Ready(ev) = self.mdns.poll(cx, params) {
match ev {
NetworkBehaviourAction::GenerateEvent(event) => match event {
Expand Down Expand Up @@ -890,14 +882,12 @@ fn protocol_name_from_protocol_id(id: &ProtocolId) -> Vec<u8> {

/// [`Mdns::new`] returns a future. Instead of forcing [`DiscoveryConfig::finish`] and all its
/// callers to be async, lazily instantiate [`Mdns`].
#[cfg(not(target_os = "unknown"))]
enum MdnsWrapper {
Instantiating(futures::future::BoxFuture<'static, std::io::Result<Mdns>>),
Ready(Mdns),
Disabled,
}

#[cfg(not(target_os = "unknown"))]
impl MdnsWrapper {
fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec<Multiaddr> {
match self {
Expand Down
1 change: 0 additions & 1 deletion client/network/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use libp2p::{
},
identity, mplex, noise, PeerId, Transport,
};
#[cfg(not(target_os = "unknown"))]
use libp2p::{dns, tcp, websocket};
use std::{sync::Arc, time::Duration};

Expand Down
2 changes: 0 additions & 2 deletions client/offchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ sp-offchain = { version = "4.0.0-dev", path = "../../primitives/offchain" }
sp-runtime = { version = "4.0.0-dev", path = "../../primitives/runtime" }
sc-utils = { version = "4.0.0-dev", path = "../utils" }
threadpool = "1.7"

[target.'cfg(not(target_os = "unknown"))'.dependencies]
hyper = "0.14.11"
hyper-rustls = "0.22.1"

Expand Down
6 changes: 0 additions & 6 deletions client/offchain/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@ use sp_core::{
};
pub use sp_offchain::STORAGE_PREFIX;

#[cfg(not(target_os = "unknown"))]
mod http;

#[cfg(target_os = "unknown")]
use http_dummy as http;
#[cfg(target_os = "unknown")]
mod http_dummy;

mod timestamp;

fn unavailable_yet<R: Default>(name: &str) -> R {
Expand Down
Loading