Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2024-04-08 10:56:40 +03:00
parent 75ace42366
commit c8020c92fe
3 changed files with 87 additions and 35 deletions
@@ -166,10 +166,29 @@ async fn light_client_testing() -> Result<(), subxt::Error> {
tracing_subscriber::fmt::init();
let now = std::time::Instant::now();
println!("Init lightclient");
// let chainspec = subxt::utils::fetch_chainspec_from_rpc_node("wss://rpc.polkadot.io:443")
// let chainspec = subxt::utils::fetch_chainspec_from_rpc_node("ws://127.0.0.1:9944")
// .await
// .unwrap();
// println!("Fetch spec took {:?}\n", now.elapsed());
// let bootnode = format!(
// "/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWHdiAxVd8uMQR1hGWXccidmfCwLqcMpGwR6QcTP6QRMuD",
// );
// let chain_config = subxt::lightclient::ChainConfig::chain_spec(chainspec.get())
// .set_bootnodes([bootnode.as_str()])
// .map_err(|e| format!("Light client: cannot update boot nodes: {e}"))?;
let chainspec = subxt::utils::fetch_chainspec_from_rpc_node("wss://rpc.polkadot.io:443")
.await
.unwrap();
let (_lc, rpc) = LightClient::relay_chain(chainspec.get())?;
println!("Chain Spec: {:?}", chainspec);
let chain_config = chainspec.get();
let (_lc, rpc) = LightClient::relay_chain(chain_config)?;
let api = Client::from_rpc_client(rpc).await?;
println!("Light client initialization took {:?}\n", now.elapsed());