MCPcopy Create free account
hub / github.com/enviodev/hypersync-client-python / get_with_rate_limit

Method get_with_rate_limit

src/lib.rs:227–257  ·  view source on GitHub ↗

Get blockchain data for a single query, with rate limit info

(
        &'py self,
        query: Query,
        py: Python<'py>,
    )

Source from the content-addressed store, hash-verified

225
226 /// Get blockchain data for a single query, with rate limit info
227 pub fn get_with_rate_limit<'py>(
228 &'py self,
229 query: Query,
230 py: Python<'py>,
231 ) -> PyResult<Bound<'py, PyAny>> {
232 let inner = Arc::clone(&self.inner);
233
234 future_into_py(py, async move {
235 let query = query.try_convert().context("parse query")?;
236
237 let res = inner
238 .get_with_rate_limit(&query)
239 .await
240 .context("get with rate limit")?;
241
242 // On HTTP 429 the response is `None`; inspect rate_limit and retry later.
243 let (response, rate_limit) = match res {
244 hypersync_client::RateLimitResponse::Success {
245 response,
246 rate_limit,
247 } => (
248 Some(convert_response(response).context("convert response")?),
249 rate_limit,
250 ),
251 hypersync_client::RateLimitResponse::RateLimited(rate_limit) => (None, rate_limit),
252 };
253 let rate_limit: RateLimitInfo = rate_limit.into();
254
255 Ok((response, rate_limit))
256 })
257 }
258
259 /// Get the most recently observed rate limit information.
260 /// Returns None if no requests have been made yet.

Callers

nothing calls this directly

Calls 2

convert_responseFunction · 0.85
try_convertMethod · 0.45

Tested by

no test coverage detected