ChainSpec trait (#5185)

* ChainSpec trait

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Added docs

* Fixed build

* Fixed build

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Arkadiy Paronyan
2020-03-12 00:00:10 +01:00
committed by GitHub
parent d2345e8d5c
commit dc0bf210fb
38 changed files with 354 additions and 335 deletions
+6 -6
View File
@@ -19,7 +19,7 @@ use log::{debug, info};
use std::sync::Arc;
use sc_service::{
AbstractService, RpcSession, Roles, Configuration, config::{DatabaseConfig, KeystoreConfig},
ChainSpec, RuntimeGenesis
GenericChainSpec, RuntimeGenesis
};
use wasm_bindgen::prelude::*;
use futures::{prelude::*, channel::{oneshot, mpsc}, future::{poll_fn, ok}, compat::*};
@@ -34,11 +34,11 @@ pub use console_log::init_with_level as init_console_log;
/// Create a service configuration from a chain spec.
///
/// This configuration contains good defaults for a browser light client.
pub async fn browser_configuration<G, E>(chain_spec: ChainSpec<G, E>)
-> Result<Configuration<G, E>, Box<dyn std::error::Error>>
pub async fn browser_configuration<G, E>(chain_spec: GenericChainSpec<G, E>)
-> Result<Configuration, Box<dyn std::error::Error>>
where
G: RuntimeGenesis,
E: Extension,
G: RuntimeGenesis + 'static,
E: Extension + 'static,
{
let name = chain_spec.name().to_string();
@@ -46,7 +46,7 @@ where
let mut config = Configuration::default();
config.network.boot_nodes = chain_spec.boot_nodes().to_vec();
config.telemetry_endpoints = chain_spec.telemetry_endpoints().clone();
config.chain_spec = Some(chain_spec);
config.chain_spec = Some(Box::new(chain_spec));
config.network.transport = sc_network::config::TransportConfig::Normal {
wasm_external_transport: Some(transport.clone()),
allow_private_ipv4: true,