Skip to content

Commit

Permalink
Make the number of concurrent rpc queries configurable for substrate …
Browse files Browse the repository at this point in the history
…provider (#207)
  • Loading branch information
Wizdave97 authored May 10, 2024
1 parent 711fd0c commit 6166617
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tesseract/substrate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ pub struct SubstrateConfig {
pub signer: Option<String>,
/// Latest state machine height
pub latest_height: Option<u64>,
/// Max concurrent rpc requests allowed
pub max_concurent_queries: Option<u64>,
}

/// Core substrate client.
Expand All @@ -77,6 +79,8 @@ pub struct SubstrateClient<C: subxt::Config> {
pub address: Vec<u8>,
/// Latest state machine height.
initial_height: u64,
/// Max concurrent rpc requests allowed
max_concurent_queries: Option<u64>,
}

impl<C> SubstrateClient<C>
Expand Down Expand Up @@ -122,6 +126,7 @@ where
signer,
address,
initial_height: latest_height,
max_concurent_queries: config.max_concurent_queries,
})
}

Expand Down Expand Up @@ -170,6 +175,7 @@ impl<C: subxt::Config> Clone for SubstrateClient<C> {
signer: self.signer.clone(),
address: self.address.clone(),
initial_height: self.initial_height,
max_concurent_queries: self.max_concurent_queries,
}
}
}
2 changes: 1 addition & 1 deletion tesseract/substrate/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ where
}

fn max_concurrent_queries(&self) -> usize {
50
self.max_concurent_queries.unwrap_or(10) as usize
}
}

Expand Down

0 comments on commit 6166617

Please sign in to comment.