pub async fn query_cup_endpoint(
        &self,
        param: Option<CatchUpPackageParam>,
    ) -> Result<Option<pb::CatchUpPackage>, String> {
        let body = param
            .and_then(|param| serde_cbor::to_vec(&param).ok())
            .unwrap_or_default();
        let bytes = self
            .http_client
            .post_with_response(
                &self.url,
                CATCH_UP_PACKAGE_PATH,
                body,
                tokio::time::Instant::now() + Duration::from_secs(10),
            )
            .await?;

        // Response is either empty or a protobuf encoded byte stream.
        let cup = if bytes.is_empty() {
            None
        } else {
            Some(pb::CatchUpPackage::decode(&bytes[..]).map_err(|e| {
                format!(
                    "Failed to deserialize CUP from protobuf, got: {:?} - error {:?}",
                    bytes, e
                )
            })?)
        };

        Ok(cup)
    }
/// Queries the cup endpoint given the provided CatchUpPackageParams.
Queries the cup endpoint given the provided CatchUpPackageParams.
Queries the cup endpoint given the provided CatchUpPackageParams .
pub async fn query_cup_endpoint(
        &self,
        param: Option<CatchUpPackageParam>,
    ) -> Result<Option<pb::CatchUpPackage>, String> {
        let body = param
            .and_then(|param| serde_cbor::to_vec(&param).ok())
            .unwrap_or_default();
        let bytes = self
            .http_client
            .post_with_response(
                &self.url,
                CATCH_UP_PACKAGE_PATH,
                body,
                tokio::time::Instant::now() + Duration::from_secs(10),
            )
            .await?;
        // Response is either empty or a protobuf encoded byte stream.
        let cup = if bytes.is_empty() {
            None
        } else {
            Some(pb::CatchUpPackage::decode(&bytes[..]).map_err(|e| {
                format!(
                    "Failed to deserialize CUP from protobuf, got: {:?} - error {:?}",
                    bytes, e
                )
            })?)
        };
        Ok(cup)
    }
pub async fn query_cup_endpoint ( & self , param : Option < CatchUpPackageParam > , ) -> Result < Option < pb :: CatchUpPackage > , String > { let body = param . and_then ( | param | serde_cbor :: to_vec ( & param ) . ok ( ) ) . unwrap_or_default ( ) ; let bytes = self . http_client . post_with_response ( & self . url , CATCH_UP_PACKAGE_PATH , body , tokio :: time :: Instant :: now ( ) + Duration :: from_secs ( 10 ) , ) . await ? ; // Response is either empty or a protobuf encoded byte stream. let cup = if bytes . is_empty ( ) { None } else { Some ( pb :: CatchUpPackage :: decode ( & bytes [ .. ] ) . map_err ( | e | { format ! ( " " bytes e ) } ) ? ) } ; Ok ( cup ) }
Queries the cup endpoint given the provided CatchUpPackageParams.
Queries the cup endpoint given the provided CatchUpPackageParams .
&self
param
Option<CatchUpPackageParam>
&self
param
Option<CatchUpPackageParam>