Skip to content

Commit

Permalink
fix(apps/hermes): filter coming soon feeds from v2/price_feeds (#1818)
Browse files Browse the repository at this point in the history
* fix hermes latest price feeds

* revert filter null byte change
  • Loading branch information
cctdaniel authored Aug 22, 2024
1 parent 71d0323 commit 43bf766
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/hermes/server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/hermes/server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hermes"
version = "0.5.15"
version = "0.5.16"
description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle."
edition = "2021"

Expand Down
18 changes: 13 additions & 5 deletions apps/hermes/server/src/network/pythnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use {
},
borsh::BorshDeserialize,
futures::stream::StreamExt,
pyth_sdk::PriceIdentifier,
pyth_sdk_solana::state::{
load_mapping_account,
load_product_account,
Expand Down Expand Up @@ -384,13 +385,20 @@ pub async fn fetch_and_store_price_feeds_metadata<S>(
rpc_client: &RpcClient,
) -> Result<Vec<PriceFeedMetadata>>
where
S: PriceFeedMeta,
S: PriceFeedMeta + Aggregates,
{
let price_feeds_metadata = fetch_price_feeds_metadata(mapping_address, rpc_client).await?;
state
.store_price_feeds_metadata(&price_feeds_metadata)
.await?;
Ok(price_feeds_metadata)
let all_ids = Aggregates::get_price_feed_ids(state).await;

// Filter price_feeds_metadata to only include entries with IDs in all_ids
let filtered_metadata: Vec<PriceFeedMetadata> = price_feeds_metadata
.into_iter()
.filter(|metadata| all_ids.contains(&PriceIdentifier::from(metadata.id)))
.collect();


state.store_price_feeds_metadata(&filtered_metadata).await?;
Ok(filtered_metadata)
}

async fn fetch_price_feeds_metadata(
Expand Down

0 comments on commit 43bf766

Please sign in to comment.