mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 17:31:05 +00:00
Protocol ID configurable in the chain spec (#811)
* Protocol ID configurable in the chain spec * Removed obsolete const
This commit is contained in:
committed by
Gav Wood
parent
37102611d4
commit
0ab3b2de35
@@ -76,6 +76,7 @@ struct ChainSpecFile {
|
||||
pub id: String,
|
||||
pub boot_nodes: Vec<String>,
|
||||
pub telemetry_url: Option<String>,
|
||||
pub protocol_id: Option<String>,
|
||||
}
|
||||
|
||||
/// A configuration of a chain. Can be used to build a genesis block.
|
||||
@@ -101,6 +102,10 @@ impl<G: RuntimeGenesis> ChainSpec<G> {
|
||||
self.spec.telemetry_url.as_ref().map(String::as_str)
|
||||
}
|
||||
|
||||
pub fn protocol_id(&self) -> Option<&str> {
|
||||
self.spec.protocol_id.as_ref().map(String::as_str)
|
||||
}
|
||||
|
||||
/// Parse json content into a `ChainSpec`
|
||||
pub fn from_embedded(json: &'static [u8]) -> Result<Self, String> {
|
||||
let spec = json::from_slice(json).map_err(|e| format!("Error parsing spec file: {}", e))?;
|
||||
@@ -126,7 +131,8 @@ impl<G: RuntimeGenesis> ChainSpec<G> {
|
||||
id: &str,
|
||||
constructor: fn() -> G,
|
||||
boot_nodes: Vec<String>,
|
||||
telemetry_url: Option<&str>
|
||||
telemetry_url: Option<&str>,
|
||||
protocol_id: Option<&str>,
|
||||
) -> Self
|
||||
{
|
||||
let spec = ChainSpecFile {
|
||||
@@ -134,6 +140,7 @@ impl<G: RuntimeGenesis> ChainSpec<G> {
|
||||
id: id.to_owned(),
|
||||
boot_nodes: boot_nodes,
|
||||
telemetry_url: telemetry_url.map(str::to_owned),
|
||||
protocol_id: protocol_id.map(str::to_owned),
|
||||
};
|
||||
ChainSpec {
|
||||
spec,
|
||||
|
||||
Reference in New Issue
Block a user