Skip to content
Snippets Groups Projects
Verified Commit fa298dad authored by Pascal Engélibert's avatar Pascal Engélibert :bicyclist:
Browse files

opti: concurrent requests

parent a4d1532c
No related branches found
No related tags found
No related merge requests found
...@@ -815,6 +815,7 @@ dependencies = [ ...@@ -815,6 +815,7 @@ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
"env_logger", "env_logger",
"futures",
"graphql_client", "graphql_client",
"hex", "hex",
"logs", "logs",
......
...@@ -11,6 +11,7 @@ anyhow = "1.0" ...@@ -11,6 +11,7 @@ anyhow = "1.0"
clap = { version = "3.0", features = ["derive"] } clap = { version = "3.0", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.1.5" } codec = { package = "parity-scale-codec", version = "3.1.5" }
env_logger = "0.9.0" env_logger = "0.9.0"
futures = "0.3.21"
graphql_client = { version = "0.11.0", features = ["reqwest"] } graphql_client = { version = "0.11.0", features = ["reqwest"] }
hex = "0.4.3" hex = "0.4.3"
logs = "0.5" logs = "0.5"
......
...@@ -4,6 +4,7 @@ mod indexer; ...@@ -4,6 +4,7 @@ mod indexer;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use clap::Parser; use clap::Parser;
use codec::Encode; use codec::Encode;
use futures::join;
use sp_core::{ use sp_core::{
crypto::{AccountId32, DeriveJunction, Pair as _, Ss58Codec}, crypto::{AccountId32, DeriveJunction, Pair as _, Ss58Codec},
sr25519::Pair, sr25519::Pair,
...@@ -271,19 +272,19 @@ async fn main() -> Result<()> { ...@@ -271,19 +272,19 @@ async fn main() -> Result<()> {
.fetch(&gdev_300::storage().system().parent_hash(), None) .fetch(&gdev_300::storage().system().parent_hash(), None)
.await? .await?
.unwrap(); .unwrap();
let current_block = client let addr_current_block = gdev_300::storage().system().number();
let addr_current_session = gdev_300::storage().session().current_index();
let (current_block, current_session) = join!(
client
.storage() .storage()
.fetch(&gdev_300::storage().system().number(), Some(parent_hash)) .fetch(&addr_current_block, Some(parent_hash)),
.await? client
.unwrap();
let current_session = client
.storage() .storage()
.fetch( .fetch(&addr_current_session, Some(parent_hash),)
&gdev_300::storage().session().current_index(), );
Some(parent_hash), let current_block = current_block?.unwrap();
) let current_session = current_session?.unwrap();
.await?
.unwrap();
let end_block = current_block + blocks; let end_block = current_block + blocks;
let end_session = current_session + sessions; let end_session = current_session + sessions;
...@@ -592,20 +593,16 @@ async fn main() -> Result<()> { ...@@ -592,20 +593,16 @@ async fn main() -> Result<()> {
async fn gen_revoc_doc(api: &Client, pair: &Pair) -> Result<()> { async fn gen_revoc_doc(api: &Client, pair: &Pair) -> Result<()> {
let account_id: sp_core::crypto::AccountId32 = pair.public().into(); let account_id: sp_core::crypto::AccountId32 = pair.public().into();
let idty_index = api let addr_idty_index = gdev_300::storage()
.storage()
.fetch(
&gdev_300::storage()
.identity() .identity()
.identity_index_of(&account_id), .identity_index_of(&account_id);
None, let addr_block_hash = gdev_300::storage().system().block_hash(0);
) let (idty_index, genesis_hash) = join!(
.await?; api.storage().fetch(&addr_idty_index, None,),
let genesis_hash = api api.storage().fetch(&addr_block_hash, None)
.storage() );
.fetch(&gdev_300::storage().system().block_hash(0), None) let idty_index = idty_index?.unwrap();
.await? let genesis_hash = genesis_hash?.unwrap();
.unwrap();
let payload = (b"revo", genesis_hash, idty_index).encode(); let payload = (b"revo", genesis_hash, idty_index).encode();
let signature = pair.sign(&payload); let signature = pair.sign(&payload);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment