mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 19:51:05 +00:00
Telemetry per node (#7463)
This commit is contained in:
@@ -18,7 +18,6 @@ futures01 = { package = "futures", version = "0.1.29" }
|
||||
log = "0.4.8"
|
||||
libp2p-wasm-ext = { version = "0.27", features = ["websocket"] }
|
||||
console_error_panic_hook = "0.1.6"
|
||||
console_log = "0.2.0"
|
||||
js-sys = "0.3.34"
|
||||
wasm-bindgen = "0.2.57"
|
||||
wasm-bindgen-futures = "0.4.18"
|
||||
@@ -28,6 +27,8 @@ sc-informant = { version = "0.8.0", path = "../../client/informant" }
|
||||
sc-service = { version = "0.8.0", path = "../../client/service", default-features = false }
|
||||
sc-network = { path = "../../client/network", version = "0.8.0"}
|
||||
sc-chain-spec = { path = "../../client/chain-spec", version = "2.0.0"}
|
||||
sc-telemetry = { path = "../../client/telemetry", version = "2.0.0"}
|
||||
sc-tracing = { path = "../../client/tracing", version = "2.0.0"}
|
||||
|
||||
# Imported just for the `wasm-bindgen` feature
|
||||
getrandom = { version = "0.2", features = ["js"] }
|
||||
|
||||
@@ -24,6 +24,8 @@ use sc_service::{
|
||||
GenericChainSpec, RuntimeGenesis,
|
||||
KeepBlocks, TransactionStorageMode,
|
||||
};
|
||||
use sc_telemetry::TelemetryHandle;
|
||||
use sc_tracing::logging::GlobalLoggerBuilder;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use futures::{
|
||||
prelude::*, channel::{oneshot, mpsc}, compat::*, future::{ready, ok, select}
|
||||
@@ -33,20 +35,31 @@ use sc_chain_spec::Extension;
|
||||
use libp2p_wasm_ext::{ExtTransport, ffi};
|
||||
|
||||
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;
|
||||
|
||||
/// Initialize the logger and return a `TelemetryWorker` and a wasm `ExtTransport`.
|
||||
pub fn init_logging_and_telemetry(
|
||||
pattern: &str,
|
||||
) -> Result<sc_telemetry::TelemetryWorker, sc_tracing::logging::Error> {
|
||||
let transport = ExtTransport::new(ffi::websocket_transport());
|
||||
let mut logger = GlobalLoggerBuilder::new(pattern);
|
||||
logger.with_transport(transport);
|
||||
logger.init()
|
||||
}
|
||||
|
||||
/// 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>(chain_spec: GenericChainSpec<G, E>)
|
||||
-> Result<Configuration, Box<dyn std::error::Error>>
|
||||
pub async fn browser_configuration<G, E>(
|
||||
chain_spec: GenericChainSpec<G, E>,
|
||||
telemetry_handle: Option<TelemetryHandle>,
|
||||
) -> Result<Configuration, Box<dyn std::error::Error>>
|
||||
where
|
||||
G: RuntimeGenesis + 'static,
|
||||
E: Extension + 'static + Send + Sync,
|
||||
{
|
||||
let name = chain_spec.name().to_string();
|
||||
|
||||
let transport = ExtTransport::new(ffi::websocket_transport());
|
||||
|
||||
let mut network = NetworkConfiguration::new(
|
||||
format!("{} (Browser)", name),
|
||||
"unknown",
|
||||
@@ -69,6 +82,7 @@ where
|
||||
async {}
|
||||
}).into(),
|
||||
telemetry_external_transport: Some(transport),
|
||||
telemetry_handle,
|
||||
role: Role::Light,
|
||||
database: {
|
||||
info!("Opening Indexed DB database '{}'...", name);
|
||||
|
||||
Reference in New Issue
Block a user