mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 19:51:02 +00:00
RPCs for versioning (#175)
* RPCs for versioning. * Build fix for bad merge. * Add system_name RPC * Fix tests. * Fix demo build. * Remove BadFormat.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "polkadot-cli"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
description = "Polkadot node implementation in Rust."
|
||||
|
||||
|
||||
+24
-4
@@ -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<String> {
|
||||
Ok("parity-polkadot".into())
|
||||
}
|
||||
|
||||
fn system_version(&self) -> substrate_rpc::system::error::Result<String> {
|
||||
Ok(crate_version!().into())
|
||||
}
|
||||
|
||||
fn system_chain(&self) -> substrate_rpc::system::error::Result<String> {
|
||||
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<I, T>(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<B, E>(mut core: reactor::Core, service: service::Service<B, E>, matches: &clap::ArgMatches) -> error::Result<()>
|
||||
fn run_until_exit<B, E>(mut core: reactor::Core, service: service::Service<B, E>, 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<B, E>(mut core: reactor::Core, service: service::Service<B, E>
|
||||
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())),
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user