diff --git a/src/agent.rs b/src/agent.rs index 7adab35..c30262a 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -82,7 +82,6 @@ pub mod metrics; pub mod pyth; pub mod solana; pub mod state; -pub mod store; lazy_static! { /// A static exit flag to indicate to running threads that we're shutting down. This is used to diff --git a/src/agent/metrics.rs b/src/agent/metrics.rs index 812acd4..c5f7e5a 100644 --- a/src/agent/metrics.rs +++ b/src/agent/metrics.rs @@ -3,10 +3,7 @@ use { local::PriceInfo, State, }, - crate::agent::{ - solana::oracle::PriceEntry, - store::PriceIdentifier, - }, + crate::agent::solana::oracle::PriceEntry, lazy_static::lazy_static, prometheus_client::{ encoding::{ @@ -366,7 +363,7 @@ impl PriceLocalMetrics { metrics } - pub fn update(&self, price_id: &PriceIdentifier, price_info: &PriceInfo) { + pub fn update(&self, price_id: &pyth_sdk::Identifier, price_info: &PriceInfo) { #[deny(unused_variables)] let Self { price, diff --git a/src/agent/solana/exporter.rs b/src/agent/solana/exporter.rs index ed412d1..9fd3dde 100644 --- a/src/agent/solana/exporter.rs +++ b/src/agent/solana/exporter.rs @@ -1,7 +1,6 @@ use { self::transaction_monitor::TransactionMonitor, super::{ - super::store::PriceIdentifier, key_store, network::Network, oracle::PricePublishingMetadata, @@ -242,7 +241,7 @@ pub struct Exporter { /// The last state published for each price identifier. Used to /// rule out stale data and prevent repetitive publishing of /// unchanged prices. - last_published_state: HashMap, + last_published_state: HashMap, /// Watch receiver channel to access the current network state network_state_rx: watch::Receiver, @@ -417,7 +416,7 @@ impl Exporter { } } - async fn get_permissioned_updates(&mut self) -> Result> { + async fn get_permissioned_updates(&mut self) -> Result> { let local_store_contents = self.fetch_local_store_contents().await?; let publish_keypair = self.get_publish_keypair().await?; @@ -595,7 +594,7 @@ impl Exporter { }); } - async fn fetch_local_store_contents(&self) -> Result> { + async fn fetch_local_store_contents(&self) -> Result> { Ok(LocalStore::get_all_price_infos(&*self.state).await) } diff --git a/src/agent/state.rs b/src/agent/state.rs index 61ebf64..cb99635 100644 --- a/src/agent/state.rs +++ b/src/agent/state.rs @@ -6,7 +6,6 @@ use { NotifyPriceSched, SubscriptionID, }, - store::PriceIdentifier, }, serde::{ Deserialize, diff --git a/src/agent/state/api.rs b/src/agent/state/api.rs index d8d917d..98944d2 100644 --- a/src/agent/state/api.rs +++ b/src/agent/state/api.rs @@ -19,7 +19,6 @@ use { network::Network, oracle::PriceEntry, }, - store::PriceIdentifier, }, global::{ AllAccountsData, @@ -138,8 +137,8 @@ fn solana_price_account_to_pythd_api_price_account( } } -type PriceSubscriptions = HashMap>; -type PriceSchedSubscribtions = HashMap>; +type PriceSubscriptions = HashMap>; +type PriceSchedSubscribtions = HashMap>; #[derive(Default)] pub struct PricesState { diff --git a/src/agent/state/local.rs b/src/agent/state/local.rs index 60e3f7b..355e039 100644 --- a/src/agent/state/local.rs +++ b/src/agent/state/local.rs @@ -2,10 +2,7 @@ // is contributing to the network. The Exporters will then take this data and publish // it to the networks. use { - super::{ - PriceIdentifier, - State, - }, + super::State, crate::agent::metrics::PriceLocalMetrics, anyhow::{ anyhow, @@ -45,7 +42,7 @@ impl PriceInfo { } pub struct Store { - prices: RwLock>, + prices: RwLock>, metrics: PriceLocalMetrics, logger: Logger, } @@ -62,8 +59,12 @@ impl Store { #[async_trait::async_trait] pub trait LocalStore { - async fn update(&self, price_identifier: PriceIdentifier, price_info: PriceInfo) -> Result<()>; - async fn get_all_price_infos(&self) -> HashMap; + async fn update( + &self, + price_identifier: pyth_sdk::Identifier, + price_info: PriceInfo, + ) -> Result<()>; + async fn get_all_price_infos(&self) -> HashMap; } // Allow downcasting State into GlobalStore for functions that depend on the `GlobalStore` service. @@ -79,7 +80,11 @@ where for<'a> &'a T: Into<&'a Store>, T: Sync, { - async fn update(&self, price_identifier: PriceIdentifier, price_info: PriceInfo) -> Result<()> { + async fn update( + &self, + price_identifier: pyth_sdk::Identifier, + price_info: PriceInfo, + ) -> Result<()> { debug!(self.into().logger, "local store received price update"; "identifier" => bs58::encode(price_identifier.to_bytes()).into_string()); // Drop the update if it is older than the current one stored for the price @@ -102,7 +107,7 @@ where Ok(()) } - async fn get_all_price_infos(&self) -> HashMap { + async fn get_all_price_infos(&self) -> HashMap { self.into().prices.read().await.clone() } } diff --git a/src/agent/store.rs b/src/agent/store.rs deleted file mode 100644 index 6f0bb24..0000000 --- a/src/agent/store.rs +++ /dev/null @@ -1 +0,0 @@ -pub type PriceIdentifier = pyth_sdk::Identifier;