From c3258d54069876bdeccd797385a892cd847f693d Mon Sep 17 00:00:00 2001 From: Tejas Badadare Date: Wed, 6 Nov 2024 13:03:23 -0800 Subject: [PATCH] fix(hermes): make `ignore_invalid_price_ids` param optional on the SSE stream API (#2102) --- apps/hermes/server/Cargo.lock | 2 +- apps/hermes/server/Cargo.toml | 2 +- apps/hermes/server/src/api/rest/v2/sse.rs | 32 +++++------------------ 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/apps/hermes/server/Cargo.lock b/apps/hermes/server/Cargo.lock index 3007dc2107..1ac0e51262 100644 --- a/apps/hermes/server/Cargo.lock +++ b/apps/hermes/server/Cargo.lock @@ -1796,7 +1796,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermes" -version = "0.7.0" +version = "0.7.1" dependencies = [ "anyhow", "async-trait", diff --git a/apps/hermes/server/Cargo.toml b/apps/hermes/server/Cargo.toml index 231bf1bfd2..a437da3c3d 100644 --- a/apps/hermes/server/Cargo.toml +++ b/apps/hermes/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hermes" -version = "0.7.0" +version = "0.7.1" description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle." edition = "2021" diff --git a/apps/hermes/server/src/api/rest/v2/sse.rs b/apps/hermes/server/src/api/rest/v2/sse.rs index 5b6f4e042c..70c5766870 100644 --- a/apps/hermes/server/src/api/rest/v2/sse.rs +++ b/apps/hermes/server/src/api/rest/v2/sse.rs @@ -1,34 +1,19 @@ use { crate::{ api::{ - rest::{ - validate_price_ids, - RestError, - }, + rest::{validate_price_ids, RestError}, types::{ - BinaryUpdate, - EncodingType, - ParsedPriceUpdate, - PriceIdInput, - PriceUpdate, + BinaryUpdate, EncodingType, ParsedPriceUpdate, PriceIdInput, PriceUpdate, RpcPriceIdentifier, }, ApiState, }, - state::aggregate::{ - Aggregates, - AggregationEvent, - RequestTime, - }, + state::aggregate::{Aggregates, AggregationEvent, RequestTime}, }, anyhow::Result, axum::{ extract::State, - response::sse::{ - Event, - KeepAlive, - Sse, - }, + response::sse::{Event, KeepAlive, Sse}, }, futures::Stream, pyth_sdk::PriceIdentifier, @@ -36,10 +21,7 @@ use { serde_qs::axum::QsQuery, std::convert::Infallible, tokio::sync::broadcast, - tokio_stream::{ - wrappers::BroadcastStream, - StreamExt as _, - }, + tokio_stream::{wrappers::BroadcastStream, StreamExt as _}, utoipa::IntoParams, }; @@ -74,7 +56,8 @@ pub struct StreamPriceUpdatesQueryParams { #[serde(default)] benchmarks_only: bool, - /// If true, invalid price IDs in the `ids` parameter are ignored. Only applicable to the v2 APIs. Default is `false`. #[serde(default)] + /// If true, invalid price IDs in the `ids` parameter are ignored. Only applicable to the v2 APIs. Default is `false`. + #[serde(default)] ignore_invalid_price_ids: bool, } @@ -179,7 +162,6 @@ where .map(|price_feed| price_feed.into()) .collect(); - if benchmarks_only { // Remove those with metadata.prev_publish_time != price.publish_time from parsed_price_updates parsed_price_updates.retain(|price_feed| {