Skip to content

Commit 8fc1ebf

Browse files
committed
precommit
1 parent cb0fb12 commit 8fc1ebf

File tree

1 file changed

+54
-29
lines changed

1 file changed

+54
-29
lines changed

src/agent/state/oracle.rs

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
11
#[allow(deprecated)]
22
use crate::agent::legacy_schedule::LegacySchedule;
33
use {
4-
super::{super::solana::network::Network, exporter::Exporter},
4+
super::{
5+
super::solana::network::Network,
6+
exporter::Exporter,
7+
},
58
crate::agent::{
69
market_schedule::MarketSchedule,
7-
state::{global::Update, Prices, State},
10+
state::{
11+
global::Update,
12+
Prices,
13+
State,
14+
},
15+
},
16+
anyhow::{
17+
anyhow,
18+
Context,
19+
Result,
820
},
9-
anyhow::{anyhow, Context, Result},
1021
pyth_sdk_solana::state::{
11-
load_mapping_account, load_product_account, GenericPriceAccount, MappingAccount, PriceComp,
12-
PythnetPriceAccount, SolanaPriceAccount,
22+
load_mapping_account,
23+
load_product_account,
24+
GenericPriceAccount,
25+
MappingAccount,
26+
PriceComp,
27+
PythnetPriceAccount,
28+
SolanaPriceAccount,
29+
},
30+
serde::{
31+
Deserialize,
32+
Serialize,
1333
},
14-
serde::{Deserialize, Serialize},
1534
solana_client::nonblocking::rpc_client::RpcClient,
1635
solana_sdk::{
17-
account::Account, commitment_config::CommitmentLevel, pubkey::Pubkey, signature::Keypair,
36+
account::Account,
37+
commitment_config::CommitmentLevel,
38+
pubkey::Pubkey,
39+
signature::Keypair,
1840
},
1941
std::{
20-
collections::{HashMap, HashSet},
42+
collections::{
43+
HashMap,
44+
HashSet,
45+
},
2146
time::Duration,
2247
},
2348
tokio::sync::RwLock,
@@ -26,15 +51,15 @@ use {
2651

2752
#[derive(Debug, Clone)]
2853
pub struct ProductEntry {
29-
pub account_data: pyth_sdk_solana::state::ProductAccount,
30-
pub schedule: MarketSchedule,
31-
pub price_accounts: Vec<Pubkey>,
54+
pub account_data: pyth_sdk_solana::state::ProductAccount,
55+
pub schedule: MarketSchedule,
56+
pub price_accounts: Vec<Pubkey>,
3257
pub publish_interval: Option<Duration>,
3358
}
3459

3560
#[derive(Default, Debug, Clone)]
3661
pub struct PricePublishingMetadata {
37-
pub schedule: MarketSchedule,
62+
pub schedule: MarketSchedule,
3863
pub publish_interval: Option<Duration>,
3964
}
4065

@@ -52,7 +77,7 @@ pub struct PricePublishingMetadata {
5277
#[derive(Copy, Clone, Debug)]
5378
pub struct PriceEntry {
5479
// We intentionally act as if we have a truncated account where the underlying memory is unavailable.
55-
account: GenericPriceAccount<0, ()>,
80+
account: GenericPriceAccount<0, ()>,
5681
pub comp: [PriceComp; 64],
5782
}
5883

@@ -104,9 +129,9 @@ impl std::ops::Deref for PriceEntry {
104129

105130
#[derive(Default, Debug, Clone)]
106131
pub struct Data {
107-
pub mapping_accounts: HashMap<Pubkey, MappingAccount>,
108-
pub product_accounts: HashMap<Pubkey, ProductEntry>,
109-
pub price_accounts: HashMap<Pubkey, PriceEntry>,
132+
pub mapping_accounts: HashMap<Pubkey, MappingAccount>,
133+
pub product_accounts: HashMap<Pubkey, ProductEntry>,
134+
pub price_accounts: HashMap<Pubkey, PriceEntry>,
110135
/// publisher => {their permissioned price accounts => price publishing metadata}
111136
pub publisher_permissions: HashMap<Pubkey, HashMap<Pubkey, PricePublishingMetadata>>,
112137
}
@@ -115,16 +140,16 @@ pub struct Data {
115140
#[serde(default)]
116141
pub struct Config {
117142
/// The commitment level to use when reading data from the RPC node.
118-
pub commitment: CommitmentLevel,
143+
pub commitment: CommitmentLevel,
119144
/// The interval with which to poll account information.
120145
#[serde(with = "humantime_serde")]
121-
pub poll_interval_duration: Duration,
146+
pub poll_interval_duration: Duration,
122147
/// Whether subscribing to account updates over websocket is enabled
123-
pub subscriber_enabled: bool,
148+
pub subscriber_enabled: bool,
124149
/// Capacity of the channel over which the Subscriber sends updates to the Oracle
125150
pub updates_channel_capacity: usize,
126151
/// Capacity of the channel over which the Poller sends data to the Oracle
127-
pub data_channel_capacity: usize,
152+
pub data_channel_capacity: usize,
128153

129154
/// Ask the RPC for up to this many product/price accounts in a
130155
/// single request. Tune this setting if you're experiencing
@@ -137,12 +162,12 @@ pub struct Config {
137162
impl Default for Config {
138163
fn default() -> Self {
139164
Self {
140-
commitment: CommitmentLevel::Confirmed,
141-
poll_interval_duration: Duration::from_secs(5),
142-
subscriber_enabled: true,
165+
commitment: CommitmentLevel::Confirmed,
166+
poll_interval_duration: Duration::from_secs(5),
167+
subscriber_enabled: true,
143168
updates_channel_capacity: 10000,
144-
data_channel_capacity: 10000,
145-
max_lookup_batch_size: 100,
169+
data_channel_capacity: 10000,
170+
max_lookup_batch_size: 100,
146171
}
147172
}
148173
}
@@ -231,7 +256,7 @@ where
231256
network,
232257
&Update::PriceAccountUpdate {
233258
account_key: *account_key,
234-
account: price_entry,
259+
account: price_entry,
235260
},
236261
)
237262
.await?;
@@ -275,7 +300,7 @@ where
275300
product_accounts.get(&price_entry.prod)
276301
{
277302
PricePublishingMetadata {
278-
schedule: prod_entry.schedule.clone(),
303+
schedule: prod_entry.schedule.clone(),
279304
publish_interval: prod_entry.publish_interval,
280305
}
281306
} else {
@@ -326,7 +351,7 @@ where
326351
network,
327352
&Update::ProductAccountUpdate {
328353
account_key: *product_account_key,
329-
account: product_account.clone(),
354+
account: product_account.clone(),
330355
},
331356
)
332357
.await
@@ -339,7 +364,7 @@ where
339364
network,
340365
&Update::PriceAccountUpdate {
341366
account_key: *price_account_key,
342-
account: *price_account,
367+
account: *price_account,
343368
},
344369
)
345370
.await

0 commit comments

Comments
 (0)