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