Skip to content

Commit

Permalink
[rpc] limit ids (#2694)
Browse files Browse the repository at this point in the history
  • Loading branch information
vegetabledogdog committed Sep 26, 2024
1 parent 8c4168e commit 0e453b6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions crates/rooch-rpc-server/src/service/rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,23 @@ impl RpcService {
show_display: bool,
state_type: ObjectStateType,
) -> Result<Vec<IndexerObjectStateView>> {
const MAX_OBJECT_IDS: usize = 100;

let indexer_ids = match filter {
// Compatible with object_ids query after split object_states
// Do not query the indexer, directly return the states query results.
ObjectStateFilter::ObjectId(object_ids) => object_ids
.into_iter()
.map(|v| (v, IndexerStateID::default()))
.collect(),
ObjectStateFilter::ObjectId(object_ids) => {
if object_ids.len() > MAX_OBJECT_IDS {
return Err(anyhow::anyhow!(
"Too many object IDs requested. Maximum allowed: {}",
MAX_OBJECT_IDS
));
}
object_ids
.into_iter()
.map(|v| (v, IndexerStateID::default()))
.collect()
}
_ => {
self.indexer
.query_object_ids(filter, cursor, limit, descending_order, state_type)
Expand Down

0 comments on commit 0e453b6

Please sign in to comment.