Skip to content

Commit

Permalink
Honor paging limit when available (#1433)
Browse files Browse the repository at this point in the history
* Honor paging limit when available

* linter
  • Loading branch information
mkysel authored Dec 19, 2024
1 parent eccce06 commit a0791f0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions xmtp_api_grpc/src/replication_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl XmtpMlsClient for ClientV4 {
.map(|key| build_key_package_topic(key.as_slice()))
.collect();

let envelopes = self.query_v4_envelopes(topics).await?;
let envelopes = self.query_v4_envelopes(topics, 0).await?;
let key_packages: Result<Vec<_>, Error> = envelopes
.iter()
.map(|envelopes| {
Expand Down Expand Up @@ -248,7 +248,7 @@ impl XmtpMlsClient for ClientV4 {
originator_node_ids: vec![],
last_seen: None,
}),
limit: 100,
limit: req.paging_info.map_or(0, |paging| paging.limit),
})
.await
.map_err(|e| Error::new(ErrorKind::MlsError).with(e))?;
Expand Down Expand Up @@ -304,7 +304,7 @@ impl XmtpMlsClient for ClientV4 {
originator_node_ids: vec![],
last_seen: None,
}),
limit: 100,
limit: req.paging_info.map_or(0, |paging| paging.limit),
})
.await
.map_err(|e| Error::new(ErrorKind::MlsError).with(e))?;
Expand Down Expand Up @@ -418,7 +418,7 @@ impl XmtpIdentityClient for ClientV4 {
.iter()
.map(|r| build_identity_topic_from_hex_encoded(&r.inbox_id.clone()))
.collect();
let v4_envelopes = self.query_v4_envelopes(topics?).await?;
let v4_envelopes = self.query_v4_envelopes(topics?, 0).await?;
let joined_data = v4_envelopes
.into_iter()
.zip(request.requests.into_iter())
Expand Down Expand Up @@ -466,6 +466,7 @@ impl ClientV4 {
async fn query_v4_envelopes(
&self,
topics: Vec<Vec<u8>>,
limit: u32,
) -> Result<Vec<Vec<OriginatorEnvelope>>, Error> {
let requests = topics.iter().map(|topic| async {
let client = &mut self.client.clone();
Expand All @@ -476,7 +477,7 @@ impl ClientV4 {
originator_node_ids: vec![],
last_seen: None,
}),
limit: 100,
limit,
})
.await
.map_err(|err| Error::new(ErrorKind::IdentityError).with(err))?;
Expand Down

0 comments on commit a0791f0

Please sign in to comment.