mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
Fix the browser light client (#892)
* Fix browser node * Use feature instead
This commit is contained in:
@@ -5,6 +5,11 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
|||||||
description = "Polkadot node implementation in Rust."
|
description = "Polkadot node implementation in Rust."
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[package.metadata.wasm-pack.profile.release]
|
||||||
|
# `wasm-opt` has some problems on linux, see
|
||||||
|
# https://github.com/rustwasm/wasm-pack/issues/781 etc.
|
||||||
|
wasm-opt = false
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
@@ -35,6 +40,7 @@ rocksdb = [ "service/rocksdb" ]
|
|||||||
cli = [
|
cli = [
|
||||||
"tokio",
|
"tokio",
|
||||||
"sc-cli",
|
"sc-cli",
|
||||||
|
"service/full-node",
|
||||||
]
|
]
|
||||||
browser = [
|
browser = [
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ async fn start_inner(chain_spec: String, wasm_ext: browser_utils::Transport) ->
|
|||||||
info!("Roles: {:?}", config.roles);
|
info!("Roles: {:?}", config.roles);
|
||||||
|
|
||||||
// Create the service. This is the most heavy initialization step.
|
// Create the service. This is the most heavy initialization step.
|
||||||
let service = service::kusama_new_light(config, None).map_err(|e| format!("{:?}", e))?;
|
let service = service::kusama_new_light(config).map_err(|e| format!("{:?}", e))?;
|
||||||
|
|
||||||
Ok(browser_utils::start_client(service))
|
Ok(browser_utils::start_client(service))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ log = "0.4.8"
|
|||||||
futures = "0.3.4"
|
futures = "0.3.4"
|
||||||
slog = "2.5.2"
|
slog = "2.5.2"
|
||||||
hex-literal = "0.2.1"
|
hex-literal = "0.2.1"
|
||||||
av_store = { package = "polkadot-availability-store", path = "../availability-store" }
|
av_store = { package = "polkadot-availability-store", path = "../availability-store", optional = true }
|
||||||
consensus = { package = "polkadot-validation", path = "../validation" }
|
consensus = { package = "polkadot-validation", path = "../validation", optional = true }
|
||||||
polkadot-primitives = { path = "../primitives" }
|
polkadot-primitives = { path = "../primitives" }
|
||||||
polkadot-runtime = { path = "../runtime/polkadot" }
|
polkadot-runtime = { path = "../runtime/polkadot" }
|
||||||
kusama-runtime = { path = "../runtime/kusama" }
|
kusama-runtime = { path = "../runtime/kusama" }
|
||||||
polkadot-network = { path = "../network" }
|
polkadot-network = { path = "../network", optional = true }
|
||||||
polkadot-rpc = { path = "../rpc" }
|
polkadot-rpc = { path = "../rpc" }
|
||||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
@@ -55,5 +55,6 @@ sp-offchain = { package = "sp-offchain", git = "https://github.com/paritytech/su
|
|||||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["rocksdb"]
|
default = ["rocksdb", "full-node"]
|
||||||
rocksdb = ["service/rocksdb"]
|
rocksdb = ["service/rocksdb"]
|
||||||
|
full-node = ["av_store", "consensus", "polkadot-network"]
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ use sc_client::LongestChain;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use polkadot_primitives::{parachain, Hash, BlockId, AccountId, Nonce, Balance};
|
use polkadot_primitives::{parachain, Hash, BlockId, AccountId, Nonce, Balance};
|
||||||
use polkadot_network::legacy::gossip::Known;
|
#[cfg(feature = "full-node")]
|
||||||
use polkadot_network::protocol as network_protocol;
|
use polkadot_network::{legacy::gossip::Known, protocol as network_protocol};
|
||||||
use service::{error::{Error as ServiceError}, ServiceBuilder};
|
use service::{error::{Error as ServiceError}, ServiceBuilder};
|
||||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||||
use inherents::InherentDataProviders;
|
use inherents::InherentDataProviders;
|
||||||
@@ -206,6 +206,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new Polkadot service for a full node.
|
/// Create a new Polkadot service for a full node.
|
||||||
|
#[cfg(feature = "full-node")]
|
||||||
pub fn polkadot_new_full(
|
pub fn polkadot_new_full(
|
||||||
config: Configuration,
|
config: Configuration,
|
||||||
collating_for: Option<(CollatorId, parachain::Id)>,
|
collating_for: Option<(CollatorId, parachain::Id)>,
|
||||||
@@ -228,6 +229,7 @@ pub fn polkadot_new_full(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new Kusama service for a full node.
|
/// Create a new Kusama service for a full node.
|
||||||
|
#[cfg(feature = "full-node")]
|
||||||
pub fn kusama_new_full(
|
pub fn kusama_new_full(
|
||||||
config: Configuration,
|
config: Configuration,
|
||||||
collating_for: Option<(CollatorId, parachain::Id)>,
|
collating_for: Option<(CollatorId, parachain::Id)>,
|
||||||
@@ -251,12 +253,14 @@ pub fn kusama_new_full(
|
|||||||
|
|
||||||
/// Handles to other sub-services that full nodes instantiate, which consumers
|
/// Handles to other sub-services that full nodes instantiate, which consumers
|
||||||
/// of the node may use.
|
/// of the node may use.
|
||||||
|
#[cfg(feature = "full-node")]
|
||||||
pub struct FullNodeHandles {
|
pub struct FullNodeHandles {
|
||||||
/// A handle to the Polkadot networking protocol.
|
/// A handle to the Polkadot networking protocol.
|
||||||
pub polkadot_network: Option<network_protocol::Service>,
|
pub polkadot_network: Option<network_protocol::Service>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a new service for a full client.
|
/// Builds a new service for a full client.
|
||||||
|
#[cfg(feature = "full-node")]
|
||||||
pub fn new_full<Runtime, Dispatch, Extrinsic>(
|
pub fn new_full<Runtime, Dispatch, Extrinsic>(
|
||||||
mut config: Configuration,
|
mut config: Configuration,
|
||||||
collating_for: Option<(CollatorId, parachain::Id)>,
|
collating_for: Option<(CollatorId, parachain::Id)>,
|
||||||
|
|||||||
Reference in New Issue
Block a user