diff --git a/polkadot/cli/Cargo.toml b/polkadot/cli/Cargo.toml index 5ec179b273..f80b3b1d9f 100644 --- a/polkadot/cli/Cargo.toml +++ b/polkadot/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-cli" -version = "0.1.0" +version = "0.2.0" authors = ["Parity Technologies "] description = "Polkadot node implementation in Rust." diff --git a/polkadot/cli/src/lib.rs b/polkadot/cli/src/lib.rs index 0934755f20..d26ebf7556 100644 --- a/polkadot/cli/src/lib.rs +++ b/polkadot/cli/src/lib.rs @@ -95,6 +95,26 @@ impl substrate_rpc::author::AuthorApi for RpcTransactionPool { } } +struct Configuration(service::Configuration); + +impl substrate_rpc::system::SystemApi for Configuration { + fn system_name(&self) -> substrate_rpc::system::error::Result { + Ok("parity-polkadot".into()) + } + + fn system_version(&self) -> substrate_rpc::system::error::Result { + Ok(crate_version!().into()) + } + + fn system_chain(&self) -> substrate_rpc::system::error::Result { + Ok(match self.0.chain_spec { + ChainSpec::Development => "dev", + ChainSpec::LocalTestnet => "local", + ChainSpec::PoC1Testnet => "poc-1", + }.into()) + } +} + /// Parse command line arguments and start the node. /// /// IANA unassigned port ranges that we could use: @@ -189,12 +209,12 @@ pub fn run(args: I) -> error::Result<()> where config.keys = matches.values_of("key").unwrap_or_default().map(str::to_owned).collect(); match role == service::Role::LIGHT { - true => run_until_exit(core, service::new_light(config)?, &matches), - false => run_until_exit(core, service::new_full(config)?, &matches), + true => run_until_exit(core, service::new_light(config.clone())?, &matches, config), + false => run_until_exit(core, service::new_full(config.clone())?, &matches, config), } } -fn run_until_exit(mut core: reactor::Core, service: service::Service, matches: &clap::ArgMatches) -> error::Result<()> +fn run_until_exit(mut core: reactor::Core, service: service::Service, matches: &clap::ArgMatches, config: service::Configuration) -> error::Result<()> where B: client::backend::Backend + Send + Sync + 'static, E: client::CallExecutor + Send + Sync + 'static, @@ -222,7 +242,7 @@ fn run_until_exit(mut core: reactor::Core, service: service::Service inner: service.transaction_pool(), network: service.network(), }; - rpc::rpc_handler(service.client(), chain, pool) + rpc::rpc_handler(service.client(), chain, pool, Configuration(config.clone())) }; ( start_server(http_address, |address| rpc::start_http(address, handler())), diff --git a/polkadot/service/src/config.rs b/polkadot/service/src/config.rs index 177675ea70..16b39631b9 100644 --- a/polkadot/service/src/config.rs +++ b/polkadot/service/src/config.rs @@ -22,6 +22,7 @@ pub use network::NetworkConfiguration; /// The chain specification (this should eventually be replaced by a more general JSON-based chain /// specification). +#[derive(Clone)] pub enum ChainSpec { /// Whatever the current runtime is, with just Alice as an auth. Development, @@ -62,3 +63,21 @@ impl Default for Configuration { } } } + +impl Clone for Configuration { + fn clone(&self) -> Configuration { + Configuration { + roles: self.roles.clone(), + transaction_pool: transaction_pool::Options { + max_count: self.transaction_pool.max_count.clone(), + max_mem_usage: self.transaction_pool.max_mem_usage.clone(), + max_per_sender: self.transaction_pool.max_per_sender.clone(), + }, + network: self.network.clone(), + keystore_path: self.keystore_path.clone(), + database_path: self.database_path.clone(), + keys: self.keys.clone(), + chain_spec: self.chain_spec.clone(), + } + } +}