Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

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

Merged
merged 5 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 14 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions bin/node/cli/browser-demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<link rel="shortcut icon" href="/favicon.png" />
<script type="module">
import { start_client, default as init } from './pkg/node_cli.js';
import ws from './ws.js';

function log(msg) {
document.getElementsByTagName('body')[0].innerHTML += msg + '\n';
Expand All @@ -20,7 +19,7 @@
const chain_spec_text = await chain_spec_response.text();

// Build our client.
let client = await start_client(chain_spec_text, 'info', ws());
let client = await start_client(chain_spec_text, 'info');
log('Client started');

client.rpcSubscribe('{"method":"chain_subscribeNewHead","params":[],"id":1,"jsonrpc":"2.0"}',
Expand Down
148 changes: 0 additions & 148 deletions bin/node/cli/browser-demo/ws.js

This file was deleted.

10 changes: 5 additions & 5 deletions bin/node/cli/src/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ use log::info;
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 std::str::FromStr;

/// 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)
let config: Configuration<_, _> = browser_configuration(chain_spec)
expenses marked this conversation as resolved.
Show resolved Hide resolved
.await?;

info!("Substrate browser node");
Expand Down
2 changes: 1 addition & 1 deletion bin/utils/subkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ derive_more = { version = "0.99.2" }
sc-rpc = { version = "2.0.0-alpha.2", path = "../../../client/rpc" }
jsonrpc-core-client = { version = "14.0.3", features = ["http"] }
hyper = "0.12.35"
libp2p = "0.16.1"
libp2p = "0.16.2"
serde_json = "1.0"

[features]
Expand Down
2 changes: 1 addition & 1 deletion client/authority-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ codec = { package = "parity-scale-codec", default-features = false, version = "1
derive_more = "0.99.2"
futures = "0.3.1"
futures-timer = "3.0.1"
libp2p = { version = "0.16.1", default-features = false, features = ["secp256k1", "libp2p-websocket"] }
libp2p = { version = "0.16.2", default-features = false, features = ["secp256k1", "libp2p-websocket"] }
log = "0.4.8"
prost = "0.6.1"
rand = "0.7.2"
Expand Down
2 changes: 1 addition & 1 deletion client/network-gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ documentation = "https://docs.rs/sc-network-gossip"
[dependencies]
futures = "0.3.1"
futures-timer = "3.0.1"
libp2p = { version = "0.16.1", default-features = false, features = ["libp2p-websocket"] }
libp2p = { version = "0.16.2", default-features = false, features = ["libp2p-websocket"] }
log = "0.4.8"
lru = "0.4.3"
parking_lot = "0.10.0"
Expand Down
2 changes: 1 addition & 1 deletion client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ futures = "0.3.1"
futures_codec = "0.3.3"
futures-timer = "3.0.1"
wasm-timer = "0.2"
libp2p = { version = "0.16.1", default-features = false, features = ["libp2p-websocket"] }
libp2p = { version = "0.16.2", default-features = false, features = ["libp2p-websocket"] }
linked-hash-map = "0.5.2"
linked_hash_set = "0.1.3"
log = "0.4.8"
Expand Down
2 changes: 1 addition & 1 deletion client/network/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ futures = "0.1.29"
futures03 = { package = "futures", version = "0.3.1", features = ["compat"] }
futures-timer = "3.0.1"
rand = "0.7.2"
libp2p = { version = "0.16.1", default-features = false, features = ["libp2p-websocket"] }
libp2p = { version = "0.16.2", default-features = false, features = ["libp2p-websocket"] }
sp-consensus = { version = "0.8.0-alpha.2", path = "../../../primitives/consensus/common" }
sc-client = { version = "0.8.0-alpha.2", path = "../../" }
sc-client-api = { version = "2.0.0-alpha.2", path = "../../api" }
Expand Down
2 changes: 1 addition & 1 deletion client/peerset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ documentation = "https://docs.rs/sc-peerset"

[dependencies]
futures = "0.3.1"
libp2p = { version = "0.16.1", default-features = false }
libp2p = { version = "0.16.2", default-features = false }
log = "0.4.8"
serde_json = "1.0.41"
wasm-timer = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion client/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ parking_lot = "0.10.0"
futures = "0.3.1"
futures-timer = "3.0.1"
wasm-timer = "0.2.0"
libp2p = { version = "0.16.1", default-features = false, features = ["libp2p-websocket"] }
libp2p = { version = "0.16.2", default-features = false, features = ["libp2p-websocket"] }
log = "0.4.8"
pin-project = "0.4.6"
rand = "0.7.2"
Expand Down
2 changes: 1 addition & 1 deletion primitives/consensus/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ documentation = "https://docs.rs/sp-consensus/"

[dependencies]
derive_more = "0.99.2"
libp2p = { version = "0.16.1", default-features = false }
libp2p = { version = "0.16.2", default-features = false }
log = "0.4.8"
sp-core = { path= "../../core" , version = "2.0.0-alpha.2"}
sp-inherents = { version = "2.0.0-alpha.2", path = "../../inherents" }
Expand Down
2 changes: 1 addition & 1 deletion utils/browser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/substrate/"
futures = "0.3"
futures01 = { package = "futures", version = "0.1.29" }
log = "0.4.8"
libp2p = { version = "0.16.1", default-features = false }
libp2p-wasm-ext = { version = "0.16.2", features = ["websocket"] }
console_error_panic_hook = "0.1.6"
console_log = "0.1.2"
js-sys = "0.3.34"
Expand Down
Loading