Skip to content

Commit

Permalink
use efficient data structures when calling batch_simulate_bundles (#206
Browse files Browse the repository at this point in the history
…) (#207)
  • Loading branch information
segfaultdoc authored and buffalu committed Feb 14, 2023
1 parent af19b8d commit 9a4a33f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
8 changes: 3 additions & 5 deletions bench-batch-simulate-bundle/src/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Simulator {
self.t_pool.spawn(move || {
// TODO: is this slow?
if let Some((n_succeeded, n_failed)) =
Self::do_simulate(bundles, simulation_slot, &rpc_client)
Self::do_simulate(&bundles[..], simulation_slot, &rpc_client)
{
stats
.total_sim_success
Expand All @@ -96,7 +96,7 @@ impl Simulator {

/// returns (num_succeeded, num_failed) simulations
fn do_simulate(
bundles: Vec<VersionedBundle>,
bundles: &[VersionedBundle],
simulation_slot: Slot,
rpc_client: &Arc<RpcClient>,
) -> Option<(u64, u64)> {
Expand All @@ -113,9 +113,7 @@ impl Simulator {
})
.collect::<Vec<RpcSimulateBundleConfig>>();

match rpc_client
.batch_simulate_bundle_with_config(bundles.into_iter().zip(configs).collect())
{
match rpc_client.batch_simulate_bundle_with_config(bundles.iter().zip(configs).collect()) {
Ok(response) => {
let mut n_succeeded: u64 = 0;
let mut n_failed: u64 = 0;
Expand Down
6 changes: 3 additions & 3 deletions client/src/nonblocking/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ impl RpcClient {

pub async fn batch_simulate_bundle(
&self,
bundles: Vec<VersionedBundle>,
bundles: &[VersionedBundle],
) -> BatchRpcResult<RpcSimulateBundleResult> {
let configs = bundles
.iter()
Expand All @@ -1422,13 +1422,13 @@ impl RpcClient {
})
.collect::<Vec<RpcSimulateBundleConfig>>();

self.batch_simulate_bundle_with_config(bundles.into_iter().zip(configs).collect())
self.batch_simulate_bundle_with_config(bundles.iter().zip(configs).collect())
.await
}

pub async fn batch_simulate_bundle_with_config(
&self,
bundles_and_configs: Vec<(VersionedBundle, RpcSimulateBundleConfig)>,
bundles_and_configs: Vec<(&VersionedBundle, RpcSimulateBundleConfig)>,
) -> BatchRpcResult<RpcSimulateBundleResult> {
let mut params = vec![];
for (bundle, config) in bundles_and_configs {
Expand Down
4 changes: 2 additions & 2 deletions client/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,14 +1154,14 @@ impl RpcClient {

pub fn batch_simulate_bundle(
&self,
bundles: Vec<VersionedBundle>,
bundles: &[VersionedBundle],
) -> BatchRpcResult<RpcSimulateBundleResult> {
self.invoke(self.rpc_client.batch_simulate_bundle(bundles))
}

pub fn batch_simulate_bundle_with_config(
&self,
bundles_and_configs: Vec<(VersionedBundle, RpcSimulateBundleConfig)>,
bundles_and_configs: Vec<(&VersionedBundle, RpcSimulateBundleConfig)>,
) -> BatchRpcResult<RpcSimulateBundleResult> {
self.invoke(
self.rpc_client
Expand Down

0 comments on commit 9a4a33f

Please sign in to comment.