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.
## Description get_object to loadgen ## 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
6 changed files
with
172 additions
and
28 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use anyhow::Result; | ||
use futures::future::join_all; | ||
use sui_json_rpc_types::{SuiObjectDataOptions, SuiObjectResponse}; | ||
use sui_sdk::SuiClient; | ||
use sui_types::base_types::ObjectID; | ||
|
||
use crate::payload::{GetObject, ProcessPayload, RpcCommandProcessor, SignerInfo}; | ||
use async_trait::async_trait; | ||
|
||
use super::validation::chunk_entities; | ||
|
||
#[async_trait] | ||
impl<'a> ProcessPayload<'a, &'a GetObject> for RpcCommandProcessor { | ||
async fn process(&'a self, op: &'a GetObject, _signer_info: &Option<SignerInfo>) -> Result<()> { | ||
if op.object_ids.is_empty() { | ||
panic!("No object ids provided, skipping query"); | ||
}; | ||
let clients = self.get_clients().await?; | ||
let chunked = chunk_entities(&op.object_ids, Some(op.chunk_size)); | ||
|
||
for chunk in chunked { | ||
let mut tasks = Vec::new(); | ||
for object_id in chunk { | ||
for client in clients.iter() { | ||
let task = async move { | ||
get_object(client, object_id).await.unwrap(); | ||
}; | ||
tasks.push(task); | ||
} | ||
} | ||
join_all(tasks).await; | ||
} | ||
Ok(()) | ||
} | ||
} | ||
|
||
// TODO: should organize these into an api_calls.rs | ||
pub(crate) async fn get_object( | ||
client: &SuiClient, | ||
object_id: ObjectID, | ||
) -> Result<SuiObjectResponse> { | ||
let result = client | ||
.read_api() | ||
.get_object_with_options(object_id, SuiObjectDataOptions::full_content()) | ||
.await | ||
.unwrap(); | ||
Ok(result) | ||
} |
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