Polkadot companion for #8143 (#2535)

Companion for https://github.com/paritytech/substrate/pull/8143
This commit is contained in:
Cecile Tonglet
2021-03-11 12:11:04 +01:00
committed by GitHub
parent 0fac590b84
commit 7dfb666ea5
8 changed files with 245 additions and 185 deletions
+4 -7
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use browser_utils::{browser_configuration, init_logging_and_telemetry, set_console_error_panic_hook, Client};
use browser_utils::{browser_configuration, init_logging, set_console_error_panic_hook, Client};
use log::info;
use wasm_bindgen::prelude::*;
@@ -26,12 +26,11 @@ pub async fn start_client(chain_spec: String, log_level: String) -> Result<Clien
async fn start_inner(chain_spec: String, log_directives: String) -> Result<Client, Box<dyn std::error::Error>> {
set_console_error_panic_hook();
let telemetry_worker = init_logging_and_telemetry(&log_directives)?;
init_logging(&log_directives)?;
let chain_spec =
service::PolkadotChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec()).map_err(|e| format!("{:?}", e))?;
let telemetry_handle = telemetry_worker.handle();
let config = browser_configuration(chain_spec, Some(telemetry_handle)).await?;
let config = browser_configuration(chain_spec).await?;
info!("Polkadot browser node");
info!(" version {}", config.impl_version);
@@ -41,9 +40,7 @@ async fn start_inner(chain_spec: String, log_directives: String) -> Result<Clien
info!("👤 Role: {}", config.display_role());
// Create the service. This is the most heavy initialization step.
let (task_manager, rpc_handlers, _) = service::build_light(config).map_err(|e| format!("{:?}", e))?;
task_manager.spawn_handle().spawn("telemetry", telemetry_worker.run());
let (task_manager, rpc_handlers) = service::build_light(config).map_err(|e| format!("{:?}", e))?;
Ok(browser_utils::start_client(task_manager, rpc_handlers))
}