Add new RPC method to get the chain type (#5576)

* Add new RPC method to get the chain type

This adds a new RPC method to get the chain type of the running chain.
The chain type needs to be specified in the chain spec. This should make
it easier for tools/UI to display extra information without needing to
rely on parsing the chain name.

* Update client/rpc-api/src/system/mod.rs

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Primitive crate

* Feedback

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
Bastian Köcher
2020-04-08 20:41:51 +02:00
committed by GitHub
parent 1d2cbfbdf9
commit 7cdfaff12b
19 changed files with 135 additions and 26 deletions
+6 -2
View File
@@ -28,7 +28,7 @@ use sp_runtime::traits::{self, Header as HeaderT};
use self::error::Result;
pub use sc_rpc_api::system::*;
pub use self::helpers::{Properties, SystemInfo, Health, PeerInfo, NodeRole};
pub use self::helpers::{SystemInfo, Health, PeerInfo, NodeRole};
pub use self::gen_client::Client as SystemClient;
/// System API implementation
@@ -82,7 +82,11 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
Ok(self.info.chain_name.clone())
}
fn system_properties(&self) -> Result<Properties> {
fn system_type(&self) -> Result<sp_chain_spec::ChainType> {
Ok(self.info.chain_type.clone())
}
fn system_properties(&self) -> Result<sp_chain_spec::Properties> {
Ok(self.info.properties.clone())
}