1
1
#[ allow( deprecated) ]
2
2
use crate :: agent:: legacy_schedule:: LegacySchedule ;
3
3
use {
4
- super :: { super :: solana:: network:: Network , exporter:: Exporter } ,
4
+ super :: {
5
+ super :: solana:: network:: Network ,
6
+ exporter:: Exporter ,
7
+ } ,
5
8
crate :: agent:: {
6
9
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 ,
8
20
} ,
9
- anyhow:: { anyhow, Context , Result } ,
10
21
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 ,
13
33
} ,
14
- serde:: { Deserialize , Serialize } ,
15
34
solana_client:: nonblocking:: rpc_client:: RpcClient ,
16
35
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 ,
18
40
} ,
19
41
std:: {
20
- collections:: { HashMap , HashSet } ,
42
+ collections:: {
43
+ HashMap ,
44
+ HashSet ,
45
+ } ,
21
46
time:: Duration ,
22
47
} ,
23
48
tokio:: sync:: RwLock ,
@@ -26,15 +51,15 @@ use {
26
51
27
52
#[ derive( Debug , Clone ) ]
28
53
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 > ,
32
57
pub publish_interval : Option < Duration > ,
33
58
}
34
59
35
60
#[ derive( Default , Debug , Clone ) ]
36
61
pub struct PricePublishingMetadata {
37
- pub schedule : MarketSchedule ,
62
+ pub schedule : MarketSchedule ,
38
63
pub publish_interval : Option < Duration > ,
39
64
}
40
65
@@ -52,7 +77,7 @@ pub struct PricePublishingMetadata {
52
77
#[ derive( Copy , Clone , Debug ) ]
53
78
pub struct PriceEntry {
54
79
// We intentionally act as if we have a truncated account where the underlying memory is unavailable.
55
- account : GenericPriceAccount < 0 , ( ) > ,
80
+ account : GenericPriceAccount < 0 , ( ) > ,
56
81
pub comp : [ PriceComp ; 64 ] ,
57
82
}
58
83
@@ -104,9 +129,9 @@ impl std::ops::Deref for PriceEntry {
104
129
105
130
#[ derive( Default , Debug , Clone ) ]
106
131
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 > ,
110
135
/// publisher => {their permissioned price accounts => price publishing metadata}
111
136
pub publisher_permissions : HashMap < Pubkey , HashMap < Pubkey , PricePublishingMetadata > > ,
112
137
}
@@ -115,16 +140,16 @@ pub struct Data {
115
140
#[ serde( default ) ]
116
141
pub struct Config {
117
142
/// The commitment level to use when reading data from the RPC node.
118
- pub commitment : CommitmentLevel ,
143
+ pub commitment : CommitmentLevel ,
119
144
/// The interval with which to poll account information.
120
145
#[ serde( with = "humantime_serde" ) ]
121
- pub poll_interval_duration : Duration ,
146
+ pub poll_interval_duration : Duration ,
122
147
/// Whether subscribing to account updates over websocket is enabled
123
- pub subscriber_enabled : bool ,
148
+ pub subscriber_enabled : bool ,
124
149
/// Capacity of the channel over which the Subscriber sends updates to the Oracle
125
150
pub updates_channel_capacity : usize ,
126
151
/// 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 ,
128
153
129
154
/// Ask the RPC for up to this many product/price accounts in a
130
155
/// single request. Tune this setting if you're experiencing
@@ -137,12 +162,12 @@ pub struct Config {
137
162
impl Default for Config {
138
163
fn default ( ) -> Self {
139
164
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 ,
143
168
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 ,
146
171
}
147
172
}
148
173
}
@@ -231,7 +256,7 @@ where
231
256
network,
232
257
& Update :: PriceAccountUpdate {
233
258
account_key : * account_key,
234
- account : price_entry,
259
+ account : price_entry,
235
260
} ,
236
261
)
237
262
. await ?;
@@ -275,7 +300,7 @@ where
275
300
product_accounts. get ( & price_entry. prod )
276
301
{
277
302
PricePublishingMetadata {
278
- schedule : prod_entry. schedule . clone ( ) ,
303
+ schedule : prod_entry. schedule . clone ( ) ,
279
304
publish_interval : prod_entry. publish_interval ,
280
305
}
281
306
} else {
@@ -326,7 +351,7 @@ where
326
351
network,
327
352
& Update :: ProductAccountUpdate {
328
353
account_key : * product_account_key,
329
- account : product_account. clone ( ) ,
354
+ account : product_account. clone ( ) ,
330
355
} ,
331
356
)
332
357
. await
@@ -339,7 +364,7 @@ where
339
364
network,
340
365
& Update :: PriceAccountUpdate {
341
366
account_key : * price_account_key,
342
- account : * price_account,
367
+ account : * price_account,
343
368
} ,
344
369
)
345
370
. await
0 commit comments