Skip to content

Commit f89e8cc

Browse files
committed
Fix formatting
1 parent 52c115a commit f89e8cc

File tree

6 files changed

+70
-54
lines changed

6 files changed

+70
-54
lines changed

src/agent/metrics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ impl ProductGlobalMetrics {
115115
}
116116

117117
pub fn update(&self, product_key: &Pubkey, maybe_symbol: Option<SmolStr>) {
118-
let symbol_string = maybe_symbol.map(|x| x.into())
118+
let symbol_string = maybe_symbol
119+
.map(|x| x.into())
119120
.unwrap_or(format!("unknown_{}", product_key));
120121

121122
#[deny(unused_variables)]

src/agent/pyth.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ use {
33
Deserialize,
44
Serialize,
55
},
6-
std::collections::BTreeMap,
7-
std::sync::Arc,
86
smol_str::SmolStr,
7+
std::{
8+
collections::BTreeMap,
9+
sync::Arc,
10+
},
911
};
1012

1113
pub mod rpc;
@@ -18,7 +20,7 @@ pub type Exponent = i64;
1820
pub type Conf = u64;
1921
pub type Slot = u64;
2022

21-
#[derive(Serialize, Deserialize, Debug, Ord, PartialOrd, PartialEq, Eq)]
23+
#[derive(Serialize, Deserialize, Debug, Ord, PartialOrd, PartialEq, Eq)]
2224
pub struct ProductAccountMetadata {
2325
pub account: Pubkey,
2426
pub attr_dict: Attrs,

src/agent/state.rs

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl State {
9090
keypairs: keypairs::KeypairState::default(),
9191
prices: api::PricesState::new(config.state.clone()),
9292
exporter: exporter::ExporterState::new(),
93-
oracle: oracle::OracleState::default(),
93+
oracle: oracle::OracleState::default(),
9494
transactions: transactions::TransactionsState::new(
9595
config
9696
.primary_network
@@ -110,7 +110,7 @@ impl State {
110110
keypairs: keypairs::KeypairState::default(),
111111
prices: api::PricesState::new(config),
112112
exporter: exporter::ExporterState::new(),
113-
oracle: oracle::OracleState::default(),
113+
oracle: oracle::OracleState::default(),
114114
transactions: transactions::TransactionsState::new(100),
115115
}
116116
}
@@ -261,7 +261,8 @@ mod tests {
261261
"2V7t5NaKY7aGkwytCWQgvUYZfEr9XMwNChhJEakTExk6",
262262
)
263263
.unwrap(),
264-
].into(),
264+
]
265+
.into(),
265266
},
266267
),
267268
(
@@ -294,7 +295,8 @@ mod tests {
294295
"GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ",
295296
)
296297
.unwrap(),
297-
].into(),
298+
]
299+
.into(),
298300
},
299301
),
300302
]),
@@ -373,7 +375,7 @@ mod tests {
373375
]
374376
.map(|(k, v)| (k.into(), v.into())),
375377
),
376-
price: [
378+
price: [
377379
PriceAccountMetadata {
378380
account: "GG3FTE7xhc9Diy7dn9P6BWzoCrAEE4D3p5NBYrDAm5DD".into(),
379381
price_type: "price".into(),
@@ -389,7 +391,8 @@ mod tests {
389391
price_type: "price".into(),
390392
price_exponent: 2,
391393
},
392-
].into(),
394+
]
395+
.into(),
393396
},
394397
ProductAccountMetadata {
395398
account: "CkMrDWtmFJZcmAUC11qNaWymbXQKvnRx4cq1QudLav7t".into(),
@@ -404,7 +407,7 @@ mod tests {
404407
]
405408
.map(|(k, v)| (k.into(), v.into())),
406409
),
407-
price: [
410+
price: [
408411
PriceAccountMetadata {
409412
account: "GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU".into(),
410413
price_type: "price".into(),
@@ -420,7 +423,8 @@ mod tests {
420423
price_type: "price".into(),
421424
price_exponent: -6,
422425
},
423-
].into(),
426+
]
427+
.into(),
424428
},
425429
];
426430

@@ -496,7 +500,8 @@ mod tests {
496500
"2V7t5NaKY7aGkwytCWQgvUYZfEr9XMwNChhJEakTExk6",
497501
)
498502
.unwrap(),
499-
].into(),
503+
]
504+
.into(),
500505
}
501506
.into(),
502507
),
@@ -558,7 +563,8 @@ mod tests {
558563
"GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ",
559564
)
560565
.unwrap(),
561-
].into(),
566+
]
567+
.into(),
562568
}
563569
.into(),
564570
),
@@ -616,8 +622,7 @@ mod tests {
616622
},
617623
comp: [PriceComp::default(); 32],
618624
extended: (),
619-
}))
620-
,
625+
})),
621626
),
622627
(
623628
solana_sdk::pubkey::Pubkey::from_str(
@@ -1078,8 +1083,7 @@ mod tests {
10781083
),
10791084
price_accounts: [
10801085
pyth::PriceAccount {
1081-
account: "GG3FTE7xhc9Diy7dn9P6BWzoCrAEE4D3p5NBYrDAm5DD"
1082-
.into(),
1086+
account: "GG3FTE7xhc9Diy7dn9P6BWzoCrAEE4D3p5NBYrDAm5DD".into(),
10831087
price_type: "price".into(),
10841088
price_exponent: -9,
10851089
status: "trading".into(),
@@ -1107,11 +1111,11 @@ mod tests {
11071111
conf: 55896,
11081112
slot: 32976,
11091113
},
1110-
].into(),
1114+
]
1115+
.into(),
11111116
},
11121117
pyth::PriceAccount {
1113-
account: "fTNjSfj5uW9e4CAMHzUcm65ftRNBxCN1gG5GS1mYfid"
1114-
.into(),
1118+
account: "fTNjSfj5uW9e4CAMHzUcm65ftRNBxCN1gG5GS1mYfid".into(),
11151119
price_type: "price".into(),
11161120
price_exponent: -6,
11171121
status: "trading".into(),
@@ -1139,11 +1143,11 @@ mod tests {
11391143
conf: 8962196,
11401144
slot: 301541,
11411145
},
1142-
].into(),
1146+
]
1147+
.into(),
11431148
},
11441149
pyth::PriceAccount {
1145-
account: "GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ"
1146-
.into(),
1150+
account: "GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ".into(),
11471151
price_type: "price".into(),
11481152
price_exponent: 2,
11491153
status: "trading".into(),
@@ -1162,9 +1166,11 @@ mod tests {
11621166
price: 61478,
11631167
conf: 312545,
11641168
slot: 302156,
1165-
}].into(),
1169+
}]
1170+
.into(),
11661171
},
1167-
].into(),
1172+
]
1173+
.into(),
11681174
},
11691175
pyth::ProductAccount {
11701176
account: "CkMrDWtmFJZcmAUC11qNaWymbXQKvnRx4cq1QudLav7t".into(),
@@ -1181,8 +1187,7 @@ mod tests {
11811187
),
11821188
price_accounts: [
11831189
pyth::PriceAccount {
1184-
account: "GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU"
1185-
.into(),
1190+
account: "GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU".into(),
11861191
price_type: "price".into(),
11871192
price_exponent: -8,
11881193
status: "unknown".into(),
@@ -1198,8 +1203,7 @@ mod tests {
11981203
publisher_accounts: [].into(),
11991204
},
12001205
pyth::PriceAccount {
1201-
account: "3VQwtcntVQN1mj1MybQw8qK7Li3KNrrgNskSQwZAPGNr"
1202-
.into(),
1206+
account: "3VQwtcntVQN1mj1MybQw8qK7Li3KNrrgNskSQwZAPGNr".into(),
12031207
price_type: "price".into(),
12041208
price_exponent: -10,
12051209
status: "unknown".into(),
@@ -1218,11 +1222,11 @@ mod tests {
12181222
price: 85698,
12191223
conf: 23645,
12201224
slot: 14765,
1221-
}].into(),
1225+
}]
1226+
.into(),
12221227
},
12231228
pyth::PriceAccount {
1224-
account: "2V7t5NaKY7aGkwytCWQgvUYZfEr9XMwNChhJEakTExk6"
1225-
.into(),
1229+
account: "2V7t5NaKY7aGkwytCWQgvUYZfEr9XMwNChhJEakTExk6".into(),
12261230
price_type: "price".into(),
12271231
price_exponent: -6,
12281232
status: "trading".into(),
@@ -1250,9 +1254,11 @@ mod tests {
12501254
conf: 7456,
12511255
slot: 865,
12521256
},
1253-
].into(),
1257+
]
1258+
.into(),
12541259
},
1255-
].into(),
1260+
]
1261+
.into(),
12561262
},
12571263
];
12581264

@@ -1318,7 +1324,8 @@ mod tests {
13181324
price: 85698,
13191325
conf: 23645,
13201326
slot: 14765,
1321-
}].into(),
1327+
}]
1328+
.into(),
13221329
},
13231330
pyth::PriceAccount {
13241331
account: "2V7t5NaKY7aGkwytCWQgvUYZfEr9XMwNChhJEakTExk6".into(),
@@ -1349,9 +1356,11 @@ mod tests {
13491356
conf: 7456,
13501357
slot: 865,
13511358
},
1352-
].into(),
1359+
]
1360+
.into(),
13531361
},
1354-
].into(),
1362+
]
1363+
.into(),
13551364
attr_dict: BTreeMap::from(
13561365
[
13571366
("symbol", "Crypto.LTC/USD"),

src/agent/state/api.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ use {
4646
},
4747
smol_str::{
4848
SmolStr,
49-
ToSmolStr},
49+
ToSmolStr,
50+
},
5051
std::{
5152
collections::HashMap,
5253
sync::atomic::AtomicI64,

src/agent/state/global.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,25 @@ use {
2121
Result,
2222
},
2323
prometheus_client::registry::Registry,
24+
smol_str::SmolStr,
2425
solana_sdk::pubkey::Pubkey,
25-
std::{collections::{
26-
BTreeMap,
27-
HashMap,
28-
HashSet,
29-
}, sync::Arc},
26+
std::{
27+
collections::{
28+
BTreeMap,
29+
HashMap,
30+
HashSet,
31+
},
32+
sync::Arc,
33+
},
3034
tokio::sync::RwLock,
31-
smol_str::SmolStr,
3235
};
3336

3437
/// AllAccountsData contains the full data for the price and product accounts, sourced
3538
/// from the primary network.
3639
#[derive(Debug, Clone, Default)]
3740
pub struct AllAccountsData {
3841
pub product_accounts: HashMap<Pubkey, Arc<ProductEntry>>,
39-
pub price_accounts: HashMap<Pubkey, Arc<PriceEntry>>,
42+
pub price_accounts: HashMap<Pubkey, Arc<PriceEntry>>,
4043
}
4144

4245
/// AllAccountsMetadata contains the metadata for all the price and product accounts.
@@ -60,7 +63,7 @@ pub struct ProductAccountMetadata {
6063
impl From<&ProductEntry> for ProductAccountMetadata {
6164
fn from(product_account: &ProductEntry) -> Self {
6265
ProductAccountMetadata {
63-
attr_dict: product_account
66+
attr_dict: product_account
6467
.account_data
6568
.iter()
6669
.map(|(key, val)| (key.into(), val.into()))
@@ -89,11 +92,11 @@ impl From<&PriceEntry> for PriceAccountMetadata {
8992
pub enum Update {
9093
ProductAccountUpdate {
9194
account_key: Pubkey,
92-
account: Arc<ProductEntry>,
95+
account: Arc<ProductEntry>,
9396
},
9497
PriceAccountUpdate {
9598
account_key: Pubkey,
96-
account: Arc<PriceEntry>,
99+
account: Arc<PriceEntry>,
97100
},
98101
}
99102

src/agent/state/oracle.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ use {
4343
HashMap,
4444
HashSet,
4545
},
46+
sync::Arc,
4647
time::Duration,
4748
},
4849
tokio::sync::RwLock,
4950
tracing::instrument,
50-
std::sync::Arc,
5151
};
5252

5353
#[derive(Debug)]
@@ -131,8 +131,8 @@ impl std::ops::Deref for PriceEntry {
131131

132132
#[derive(Default, Debug)]
133133
pub struct Data {
134-
pub product_accounts: HashMap<Pubkey, Arc<ProductEntry>>,
135-
pub price_accounts: HashMap<Pubkey, Arc<PriceEntry>>,
134+
pub product_accounts: HashMap<Pubkey, Arc<ProductEntry>>,
135+
pub price_accounts: HashMap<Pubkey, Arc<PriceEntry>>,
136136
/// publisher => {their permissioned price accounts => price publishing metadata}
137137
pub publisher_permissions: HashMap<Pubkey, HashMap<Pubkey, PricePublishingMetadata>>,
138138
pub publisher_buffer_key: Option<Pubkey>,
@@ -247,7 +247,7 @@ where
247247
network,
248248
&Update::PriceAccountUpdate {
249249
account_key: *account_key,
250-
account: Arc::new(price_entry),
250+
account: Arc::new(price_entry),
251251
},
252252
)
253253
.await?;
@@ -370,7 +370,7 @@ where
370370
network,
371371
&Update::PriceAccountUpdate {
372372
account_key: *price_account_key,
373-
account: price_account.clone(),
373+
account: price_account.clone(),
374374
},
375375
)
376376
.await

0 commit comments

Comments
 (0)