From a0791f01ee10c84ac155151f642eac55a72083a2 Mon Sep 17 00:00:00 2001 From: Martin Kysel Date: Thu, 19 Dec 2024 08:20:38 -0500 Subject: [PATCH] Honor paging limit when available (#1433) * Honor paging limit when available * linter --- xmtp_api_grpc/src/replication_client.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xmtp_api_grpc/src/replication_client.rs b/xmtp_api_grpc/src/replication_client.rs index ee9a33141..e13b07adc 100644 --- a/xmtp_api_grpc/src/replication_client.rs +++ b/xmtp_api_grpc/src/replication_client.rs @@ -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, Error> = envelopes .iter() .map(|envelopes| { @@ -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))?; @@ -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))?; @@ -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()) @@ -466,6 +466,7 @@ impl ClientV4 { async fn query_v4_envelopes( &self, topics: Vec>, + limit: u32, ) -> Result>, Error> { let requests = topics.iter().map(|topic| async { let client = &mut self.client.clone(); @@ -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))?;