Skip to content

Commit 8a1f5ec

Browse files
committed
refactor(agent): remove store module
1 parent aea59f7 commit 8a1f5ec

File tree

7 files changed

+21
-24
lines changed

7 files changed

+21
-24
lines changed

src/agent.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ pub mod metrics;
8282
pub mod pyth;
8383
pub mod solana;
8484
pub mod state;
85-
pub mod store;
8685

8786
lazy_static! {
8887
/// A static exit flag to indicate to running threads that we're shutting down. This is used to

src/agent/metrics.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use {
33
local::PriceInfo,
44
State,
55
},
6-
crate::agent::{
7-
solana::oracle::PriceEntry,
8-
store::PriceIdentifier,
9-
},
6+
crate::agent::solana::oracle::PriceEntry,
107
lazy_static::lazy_static,
118
prometheus_client::{
129
encoding::{
@@ -366,7 +363,7 @@ impl PriceLocalMetrics {
366363
metrics
367364
}
368365

369-
pub fn update(&self, price_id: &PriceIdentifier, price_info: &PriceInfo) {
366+
pub fn update(&self, price_id: &pyth_sdk::Identifier, price_info: &PriceInfo) {
370367
#[deny(unused_variables)]
371368
let Self {
372369
price,

src/agent/solana/exporter.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use {
22
self::transaction_monitor::TransactionMonitor,
33
super::{
4-
super::store::PriceIdentifier,
54
key_store,
65
network::Network,
76
oracle::PricePublishingMetadata,
@@ -242,7 +241,7 @@ pub struct Exporter {
242241
/// The last state published for each price identifier. Used to
243242
/// rule out stale data and prevent repetitive publishing of
244243
/// unchanged prices.
245-
last_published_state: HashMap<PriceIdentifier, PriceInfo>,
244+
last_published_state: HashMap<pyth_sdk::Identifier, PriceInfo>,
246245

247246
/// Watch receiver channel to access the current network state
248247
network_state_rx: watch::Receiver<NetworkState>,
@@ -417,7 +416,7 @@ impl Exporter {
417416
}
418417
}
419418

420-
async fn get_permissioned_updates(&mut self) -> Result<Vec<(PriceIdentifier, PriceInfo)>> {
419+
async fn get_permissioned_updates(&mut self) -> Result<Vec<(pyth_sdk::Identifier, PriceInfo)>> {
421420
let local_store_contents = self.fetch_local_store_contents().await?;
422421

423422
let publish_keypair = self.get_publish_keypair().await?;
@@ -595,7 +594,7 @@ impl Exporter {
595594
});
596595
}
597596

598-
async fn fetch_local_store_contents(&self) -> Result<HashMap<PriceIdentifier, PriceInfo>> {
597+
async fn fetch_local_store_contents(&self) -> Result<HashMap<pyth_sdk::Identifier, PriceInfo>> {
599598
Ok(LocalStore::get_all_price_infos(&*self.state).await)
600599
}
601600

src/agent/state.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use {
66
NotifyPriceSched,
77
SubscriptionID,
88
},
9-
store::PriceIdentifier,
109
},
1110
serde::{
1211
Deserialize,

src/agent/state/api.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use {
1919
network::Network,
2020
oracle::PriceEntry,
2121
},
22-
store::PriceIdentifier,
2322
},
2423
global::{
2524
AllAccountsData,
@@ -138,8 +137,8 @@ fn solana_price_account_to_pythd_api_price_account(
138137
}
139138
}
140139

141-
type PriceSubscriptions = HashMap<PriceIdentifier, Vec<NotifyPriceSubscription>>;
142-
type PriceSchedSubscribtions = HashMap<PriceIdentifier, Vec<NotifyPriceSchedSubscription>>;
140+
type PriceSubscriptions = HashMap<pyth_sdk::Identifier, Vec<NotifyPriceSubscription>>;
141+
type PriceSchedSubscribtions = HashMap<pyth_sdk::Identifier, Vec<NotifyPriceSchedSubscription>>;
143142

144143
#[derive(Default)]
145144
pub struct PricesState {

src/agent/state/local.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
// is contributing to the network. The Exporters will then take this data and publish
33
// it to the networks.
44
use {
5-
super::{
6-
PriceIdentifier,
7-
State,
8-
},
5+
super::State,
96
crate::agent::metrics::PriceLocalMetrics,
107
anyhow::{
118
anyhow,
@@ -45,7 +42,7 @@ impl PriceInfo {
4542
}
4643

4744
pub struct Store {
48-
prices: RwLock<HashMap<PriceIdentifier, PriceInfo>>,
45+
prices: RwLock<HashMap<pyth_sdk::Identifier, PriceInfo>>,
4946
metrics: PriceLocalMetrics,
5047
logger: Logger,
5148
}
@@ -62,8 +59,12 @@ impl Store {
6259

6360
#[async_trait::async_trait]
6461
pub trait LocalStore {
65-
async fn update(&self, price_identifier: PriceIdentifier, price_info: PriceInfo) -> Result<()>;
66-
async fn get_all_price_infos(&self) -> HashMap<PriceIdentifier, PriceInfo>;
62+
async fn update(
63+
&self,
64+
price_identifier: pyth_sdk::Identifier,
65+
price_info: PriceInfo,
66+
) -> Result<()>;
67+
async fn get_all_price_infos(&self) -> HashMap<pyth_sdk::Identifier, PriceInfo>;
6768
}
6869

6970
// Allow downcasting State into GlobalStore for functions that depend on the `GlobalStore` service.
@@ -79,7 +80,11 @@ where
7980
for<'a> &'a T: Into<&'a Store>,
8081
T: Sync,
8182
{
82-
async fn update(&self, price_identifier: PriceIdentifier, price_info: PriceInfo) -> Result<()> {
83+
async fn update(
84+
&self,
85+
price_identifier: pyth_sdk::Identifier,
86+
price_info: PriceInfo,
87+
) -> Result<()> {
8388
debug!(self.into().logger, "local store received price update"; "identifier" => bs58::encode(price_identifier.to_bytes()).into_string());
8489

8590
// Drop the update if it is older than the current one stored for the price
@@ -102,7 +107,7 @@ where
102107
Ok(())
103108
}
104109

105-
async fn get_all_price_infos(&self) -> HashMap<PriceIdentifier, PriceInfo> {
110+
async fn get_all_price_infos(&self) -> HashMap<pyth_sdk::Identifier, PriceInfo> {
106111
self.into().prices.read().await.clone()
107112
}
108113
}

src/agent/store.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)