Use libp2p's implementation of a wasm websocket transport (#5089)

* Update to libp2p 0.16.2

* Use libp2ps implementation of a wasm websocket transport

* Remove explicit Configuration type in node-cli

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
Ashley
2020-03-10 11:14:20 +01:00
committed by GitHub
parent 1cfcf5cbfe
commit 3429967122
6 changed files with 13 additions and 165 deletions
+5 -7
View File
@@ -26,25 +26,23 @@ use futures::{prelude::*, channel::{oneshot, mpsc}, future::{poll_fn, ok}, compa
use std::task::Poll;
use std::pin::Pin;
use sc_chain_spec::Extension;
use libp2p_wasm_ext::{ExtTransport, ffi};
pub use libp2p::wasm_ext::{ExtTransport, ffi::Transport};
pub use console_error_panic_hook::set_once as set_console_error_panic_hook;
pub use console_log::init_with_level as init_console_log;
/// Create a service configuration from a chain spec and the websocket transport.
/// 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>(
transport: Transport,
chain_spec: ChainSpec<G, E>,
) -> Result<Configuration<G, E>, Box<dyn std::error::Error>>
pub async fn browser_configuration<G, E>(chain_spec: ChainSpec<G, E>)
-> Result<Configuration<G, E>, Box<dyn std::error::Error>>
where
G: RuntimeGenesis,
E: Extension,
{
let name = chain_spec.name().to_string();
let transport = ExtTransport::new(transport);
let transport = ExtTransport::new(ffi::websocket_transport());
let mut config = Configuration::default();
config.network.boot_nodes = chain_spec.boot_nodes().to_vec();
config.telemetry_endpoints = chain_spec.telemetry_endpoints().clone();