Skip to content

Commit

Permalink
refactor(agent): remove pythd module, raise pyth module
Browse files Browse the repository at this point in the history
  • Loading branch information
Reisen committed Jun 5, 2024
1 parent 87a38be commit 85fa35a
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 43 deletions.
8 changes: 4 additions & 4 deletions src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Note that there is an Oracle and Exporter for each network, but only one Local S
use {
self::{
config::Config,
pythd::api::rpc,
pyth::rpc,
solana::network,
state::notifier,
},
Expand All @@ -79,7 +79,7 @@ use {
pub mod legacy_schedule;
pub mod market_schedule;
pub mod metrics;
pub mod pythd;
pub mod pyth;
pub mod solana;
pub mod state;
pub mod store;
Expand Down Expand Up @@ -187,7 +187,7 @@ pub mod config {
use {
super::{
metrics,
pythd,
pyth,
solana::network,
state,
},
Expand All @@ -212,7 +212,7 @@ pub mod config {
#[serde(rename = "pythd_adapter")]
pub state: state::Config,
#[serde(default)]
pub pythd_api_server: pythd::api::rpc::Config,
pub pythd_api_server: pyth::rpc::Config,
#[serde(default)]
pub metrics_server: metrics::Config,
#[serde(default)]
Expand Down
4 changes: 2 additions & 2 deletions src/agent/pythd/api.rs → src/agent/pyth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use {
std::collections::BTreeMap,
};

pub mod rpc;

pub type Pubkey = String;
pub type Attrs = BTreeMap<String, String>;

Expand Down Expand Up @@ -83,5 +85,3 @@ pub struct PriceUpdate {
pub valid_slot: Slot,
pub pub_slot: Slot,
}

pub mod rpc;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion src/agent/pythd.rs

This file was deleted.

30 changes: 15 additions & 15 deletions src/agent/state.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use {
super::{
pythd::api::{
crate::agent::{
metrics::PROMETHEUS_REGISTRY,
pyth::{
NotifyPrice,
NotifyPriceSched,
SubscriptionID,
},
store::PriceIdentifier,
},
crate::agent::metrics::PROMETHEUS_REGISTRY,
serde::{
Deserialize,
Serialize,
Expand Down Expand Up @@ -100,7 +100,7 @@ mod tests {
State,
},
crate::agent::{
pythd::api::{
pyth::{
self,
NotifyPrice,
NotifyPriceSched,
Expand Down Expand Up @@ -1040,7 +1040,7 @@ mod tests {

// Check that the result of the conversion to the Pythd API format is what we expected
let expected = vec![
api::ProductAccount {
pyth::ProductAccount {
account: "BjHoZWRxo9dgbR1NQhPyTiUs6xFiX6mGS4TMYvy3b2yc".to_string(),
attr_dict: BTreeMap::from(
[
Expand All @@ -1054,7 +1054,7 @@ mod tests {
.map(|(k, v)| (k.to_string(), v.to_string())),
),
price_accounts: vec![
api::PriceAccount {
pyth::PriceAccount {
account: "GG3FTE7xhc9Diy7dn9P6BWzoCrAEE4D3p5NBYrDAm5DD"
.to_string(),
price_type: "price".to_string(),
Expand Down Expand Up @@ -1086,7 +1086,7 @@ mod tests {
},
],
},
api::PriceAccount {
pyth::PriceAccount {
account: "fTNjSfj5uW9e4CAMHzUcm65ftRNBxCN1gG5GS1mYfid"
.to_string(),
price_type: "price".to_string(),
Expand Down Expand Up @@ -1118,7 +1118,7 @@ mod tests {
},
],
},
api::PriceAccount {
pyth::PriceAccount {
account: "GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ"
.to_string(),
price_type: "price".to_string(),
Expand All @@ -1143,7 +1143,7 @@ mod tests {
},
],
},
api::ProductAccount {
pyth::ProductAccount {
account: "CkMrDWtmFJZcmAUC11qNaWymbXQKvnRx4cq1QudLav7t".to_string(),
attr_dict: BTreeMap::from(
[
Expand All @@ -1157,7 +1157,7 @@ mod tests {
.map(|(k, v)| (k.to_string(), v.to_string())),
),
price_accounts: vec![
api::PriceAccount {
pyth::PriceAccount {
account: "GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU"
.to_string(),
price_type: "price".to_string(),
Expand All @@ -1174,7 +1174,7 @@ mod tests {
prev_conf: 398674,
publisher_accounts: vec![],
},
api::PriceAccount {
pyth::PriceAccount {
account: "3VQwtcntVQN1mj1MybQw8qK7Li3KNrrgNskSQwZAPGNr"
.to_string(),
price_type: "price".to_string(),
Expand All @@ -1197,7 +1197,7 @@ mod tests {
slot: 14765,
}],
},
api::PriceAccount {
pyth::PriceAccount {
account: "2V7t5NaKY7aGkwytCWQgvUYZfEr9XMwNChhJEakTExk6"
.to_string(),
price_type: "price".to_string(),
Expand Down Expand Up @@ -1259,7 +1259,7 @@ mod tests {
let expected = ProductAccount {
account: account.to_string(),
price_accounts: vec![
api::PriceAccount {
pyth::PriceAccount {
account: "GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU".to_string(),
price_type: "price".to_string(),
price_exponent: -8,
Expand All @@ -1275,7 +1275,7 @@ mod tests {
prev_conf: 398674,
publisher_accounts: vec![],
},
api::PriceAccount {
pyth::PriceAccount {
account: "3VQwtcntVQN1mj1MybQw8qK7Li3KNrrgNskSQwZAPGNr".to_string(),
price_type: "price".to_string(),
price_exponent: -10,
Expand All @@ -1297,7 +1297,7 @@ mod tests {
slot: 14765,
}],
},
api::PriceAccount {
pyth::PriceAccount {
account: "2V7t5NaKY7aGkwytCWQgvUYZfEr9XMwNChhJEakTExk6".to_string(),
price_type: "price".to_string(),
price_exponent: -6,
Expand Down
42 changes: 21 additions & 21 deletions src/agent/state/api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
use {
super::{
super::{
pyth::{
Conf,
NotifyPrice,
NotifyPriceSched,
Price,
PriceAccount,
PriceAccountMetadata,
PriceUpdate,
ProductAccount,
ProductAccountMetadata,
PublisherAccount,
SubscriptionID,
},
solana::{
self,
network::Network,
oracle::PriceEntry,
},
store::PriceIdentifier,
},
global::{
AllAccountsData,
GlobalStore,
Expand All @@ -14,27 +35,6 @@ use {
NotifyPriceSubscription,
State,
},
crate::agent::{
pythd::api::{
Conf,
NotifyPrice,
NotifyPriceSched,
Price,
PriceAccount,
PriceAccountMetadata,
PriceUpdate,
ProductAccount,
ProductAccountMetadata,
PublisherAccount,
SubscriptionID,
},
solana::{
self,
network::Network,
oracle::PriceEntry,
},
store::PriceIdentifier,
},
anyhow::{
anyhow,
Result,
Expand Down

0 comments on commit 85fa35a

Please sign in to comment.