Unverified Commit 31a88a93 authored by Ashley's avatar Ashley
Browse files

Tidy

parent 5b33b7a7
......@@ -532,6 +532,24 @@ dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "console_error_panic_hook"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "console_log"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "const-random"
version = "0.1.6"
......@@ -3503,13 +3521,22 @@ dependencies = [
name = "polkadot-cli"
version = "0.7.1"
dependencies = [
"console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"console_log 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"polkadot-service 0.7.1",
"structopt 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"substrate-cli 2.0.0 (git+https://github.com/paritytech/substrate?branch=ashley-update-exit-future)",
"substrate-network 2.0.0 (git+https://github.com/paritytech/substrate?branch=ashley-update-exit-future)",
"substrate-service 2.0.0 (git+https://github.com/paritytech/substrate?branch=ashley-update-exit-future)",
"tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -6932,6 +6959,8 @@ dependencies = [
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
"checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
"checksum console_log 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1e7871d2947441b0fdd8e2bd1ce2a2f75304f896582c0d572162d48290683c48"
"checksum const-random 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7b641a8c9867e341f3295564203b1c250eb8ce6cb6126e007941f78c4d2ed7fe"
"checksum const-random-macro 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c750ec12b83377637110d5a57f5ae08e895b06c4b16e2bdbf1a94ef717428c59"
"checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120"
......
......@@ -17,8 +17,28 @@ structopt = "0.3.4"
cli = { package = "substrate-cli", git = "https://github.com/paritytech/substrate", branch = "ashley-update-exit-future" }
service = { package = "polkadot-service", path = "../service", default-features = false }
libp2p = { version = "0.13.0", default-features = false, optional = true }
wasm-bindgen = { version = "0.2.45", optional = true }
wasm-bindgen-futures = { version = "0.3.22", optional = true }
console_log = { version = "0.1.2", optional = true }
console_error_panic_hook = { version = "0.1.1", optional = true }
js-sys = { version = "0.3.22", optional = true }
kvdb-memorydb = { version = "0.1.1", optional = true }
substrate-service = {package = "substrate-service", git = "https://github.com/paritytech/substrate", branch = "ashley-update-exit-future", optional = true, default-features = false }
substrate-network = {package = "substrate-network", git = "https://github.com/paritytech/substrate", branch = "ashley-update-exit-future", optional = true }
[features]
default = [ "wasmtime", "rocksdb" ]
wasmtime = [ "cli/wasmtime" ]
rocksdb = [ "service/rocksdb" ]
browser = []
browser = [
"libp2p",
"wasm-bindgen",
"console_error_panic_hook",
"wasm-bindgen-futures",
"console_log",
"js-sys",
"kvdb-memorydb",
"substrate-service",
"substrate-network"
]
......@@ -19,7 +19,8 @@ use futures01::{prelude::*, sync::oneshot, sync::mpsc};
use libp2p::wasm_ext;
use log::{debug, info};
use std::sync::Arc;
use substrate_service::{AbstractService, RpcSession, Roles as ServiceRoles, Configuration, config::DatabaseConfig};
use service::{AbstractService, Roles as ServiceRoles};
use substrate_service::{RpcSession, Configuration, config::DatabaseConfig};
use wasm_bindgen::prelude::*;
/// Starts the client.
......@@ -38,9 +39,9 @@ fn start_inner(wasm_ext: wasm_ext::ffi::Transport) -> Result<Client, Box<dyn std
// Build the configuration to pass to the service.
let config = {
let wasm_ext = wasm_ext::ExtTransport::new(wasm_ext);
let chain_spec = ChainSpec::FlamingFir.load().map_err(|e| format!("{:?}", e))?;
let mut config = Configuration::<(), _, _>::default_with_spec_and_base_path(chain_spec, None);
config.network.transport = network::config::TransportConfig::Normal {
let chain_spec = ChainSpec::Kusama.load().map_err(|e| format!("{:?}", e))?;
let mut config = Configuration::<service::CustomConfiguration, _, _>::default_with_spec_and_base_path(chain_spec, None);
config.network.transport = substrate_network::config::TransportConfig::Normal {
wasm_external_transport: Some(wasm_ext.clone()),
allow_private_ipv4: true,
enable_mdns: false,
......@@ -55,15 +56,22 @@ fn start_inner(wasm_ext: wasm_ext::ffi::Transport) -> Result<Client, Box<dyn std
config
};
info!("Substrate browser node");
info!("Polkadot browser node");
info!(" version {}", config.full_version());
info!(" by Parity Technologies, 2017-2019");
info!("Chain specification: {}", config.chain_spec.name());
if config.chain_spec.name().starts_with("Kusama") {
info!("----------------------------");
info!("This chain is not in any way");
info!(" endorsed by the ");
info!(" KUSAMA FOUNDATION ");
info!("----------------------------");
}
info!("Node name: {}", config.name);
info!("Roles: {:?}", config.roles);
// Create the service. This is the most heavy initialization step.
let mut service = crate::service::new_light(config).map_err(|e| format!("{:?}", e))?;
let mut service = service::new_light(config).map_err(|e| format!("{:?}", e))?;
// We now dispatch a background task responsible for processing the service.
//
......
......@@ -20,11 +20,12 @@
#![warn(unused_extern_crates)]
mod chain_spec;
#[cfg(feature = "browser")]
mod browser;
use chain_spec::ChainSpec;
use futures::{Future, FutureExt, TryFutureExt, future::select, channel::oneshot, compat::Future01CompatExt};
use futures::{Future, future::select, channel::oneshot, compat::Future01CompatExt};
pub use tokio::runtime::Runtime;
use std::sync::Arc;
use log::{info, error};
use structopt::StructOpt;
......@@ -36,8 +37,6 @@ pub use service::{
pub use cli::{VersionInfo, IntoExit, NoCustom};
pub use cli::{display_role, error};
type BoxedFuture = Box<dyn futures01::Future<Item = (), Error = ()> + Send>;
fn load_spec(id: &str) -> Result<Option<service::ChainSpec>, String> {
Ok(match ChainSpec::from(id) {
Some(spec) => Some(spec.load()?),
......@@ -180,7 +179,7 @@ fn run_until_exit<T, SC, B, CE, W>(
let service = service
.map_err(|err| error!("Error while running Service: {}", err))
.compat();
let future = select(service, work);;
let future = select(service, work);
let _ = runtime.block_on(future);
let _ = exit_send.send(());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment