forked from airalab/robonomics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
2,314 additions
and
2,374 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2018-2020 Airalab <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
@@ -12,43 +15,41 @@ | |
// limitations under the License. | ||
// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
use log::info; | ||
use std::str::FromStr; | ||
|
||
use crate::{IsIpci, chain_spec::ChainSpec}; | ||
use wasm_bindgen::prelude::*; | ||
use sc_service::Configuration; | ||
use browser_utils::{ | ||
Transport, Client, | ||
Client, | ||
browser_configuration, set_console_error_panic_hook, init_console_log, | ||
}; | ||
use crate::{IsIpci, chain_spec::ChainSpec}; | ||
use std::str::FromStr; | ||
use log::info; | ||
|
||
/// Starts the client. | ||
#[wasm_bindgen] | ||
pub async fn start_client(chain_spec: String, log_level: String, wasm_ext: Transport) -> Result<Client, JsValue> { | ||
start_inner(chain_spec, log_level, wasm_ext) | ||
pub async fn start_client(chain_spec: String, log_level: String) -> Result<Client, JsValue> { | ||
start_inner(chain_spec, log_level) | ||
.await | ||
.map_err(|err| JsValue::from_str(&err.to_string())) | ||
} | ||
|
||
async fn start_inner(chain_spec: String, log_level: String, wasm_ext: Transport) -> Result<Client, Box<dyn std::error::Error>> { | ||
async fn start_inner(chain_spec: String, log_level: String) -> Result<Client, Box<dyn std::error::Error>> { | ||
set_console_error_panic_hook(); | ||
init_console_log(log::Level::from_str(&log_level)?)?; | ||
let chain_spec = ChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec()) | ||
.map_err(|e| format!("{:?}", e))?; | ||
|
||
let config: Configuration<_, _> = browser_configuration(wasm_ext, chain_spec) | ||
.await?; | ||
let config = browser_configuration(chain_spec).await?; | ||
|
||
info!("Robonomics Web Node"); | ||
info!("Robonomics browser node"); | ||
info!(" version {}", config.full_version()); | ||
info!(" by Airalab <[email protected]>, 2018-2020"); | ||
info!(" by Airalab, 2018-2020"); | ||
info!("Chain specification: {}", config.expect_chain_spec().name()); | ||
info!("Node name: {}", config.name); | ||
info!("Roles: {:?}", config.roles); | ||
|
||
let is_ipci = config.chain_spec.as_ref().map_or(false, |s| s.is_ipci()); | ||
// Create the service. This is the most heavy initialization step. | ||
if is_ipci { | ||
if config.expect_chain_spec().is_ipci() { | ||
let service = crate::service::new_ipci_light(config) | ||
.map_err(|e| format!("{:?}", e))?; | ||
Ok(browser_utils::start_client(service)) | ||
|
Oops, something went wrong.