forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get reference gas price (MystenLabs#10373)
## Description Use `num_chunks_per_thread` to control how many calls we make per client per thread ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
- Loading branch information
Showing
5 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
crates/sui-rpc-loadgen/src/payload/get_reference_gas_price.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use anyhow::Result; | ||
use futures::future::try_join_all; | ||
use sui_sdk::SuiClient; | ||
|
||
use crate::payload::{GetReferenceGasPrice, ProcessPayload, RpcCommandProcessor, SignerInfo}; | ||
use async_trait::async_trait; | ||
|
||
#[async_trait] | ||
impl<'a> ProcessPayload<'a, &'a GetReferenceGasPrice> for RpcCommandProcessor { | ||
async fn process( | ||
&'a self, | ||
op: &'a GetReferenceGasPrice, | ||
_signer_info: &Option<SignerInfo>, | ||
) -> Result<()> { | ||
let clients = self.get_clients().await?; | ||
|
||
let futures = (0..op.num_repeats).map(|_| { | ||
let clients = clients.clone(); | ||
async move { | ||
let futures = clients.iter().map(get_reference_gas_price); | ||
try_join_all(futures).await | ||
} | ||
}); | ||
|
||
try_join_all(futures).await.unwrap(); | ||
Ok(()) | ||
} | ||
} | ||
|
||
async fn get_reference_gas_price(client: &SuiClient) -> Result<u64> { | ||
let results = client | ||
.governance_api() | ||
.get_reference_gas_price() | ||
.await | ||
.unwrap(); | ||
Ok(results) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters