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
+5 -3
View File
@@ -107,13 +107,13 @@
//! pub type MyChainSpec<G> = GenericChainSpec<G, Extension>;
//! ```
mod chain_spec;
mod extension;
pub use chain_spec::{ChainSpec as GenericChainSpec, Properties, NoExtension};
pub use chain_spec::{ChainSpec as GenericChainSpec, NoExtension};
pub use extension::{Group, Fork, Forks, Extension, GetExtension, get_extension};
pub use sc_chain_spec_derive::{ChainSpecExtension, ChainSpecGroup};
pub use sp_chain_spec::{Properties, ChainType};
use serde::{Serialize, de::DeserializeOwned};
use sp_runtime::BuildStorage;
@@ -124,12 +124,14 @@ use sc_telemetry::TelemetryEndpoints;
pub trait RuntimeGenesis: Serialize + DeserializeOwned + BuildStorage {}
impl<T: Serialize + DeserializeOwned + BuildStorage> RuntimeGenesis for T {}
/// Common interface to `GenericChainSpec`
/// Common interface of a chain specification.
pub trait ChainSpec: BuildStorage + Send {
/// Spec name.
fn name(&self) -> &str;
/// Spec id.
fn id(&self) -> &str;
/// Type of the chain.
fn chain_type(&self) -> ChainType;
/// A list of bootnode addresses.
fn boot_nodes(&self) -> &[MultiaddrWithPeerId];
/// Telemetry endpoints (if any)