Skip to content

Commit 1edcc34

Browse files
authored
refactor: remove warnings (#129)
* refactor: remove solana/exporter.rs * refactor: remove warnings `network` field was not used in some api functions and is therefore removed. * refactor: address clippy warnings not all of them were addressable really
1 parent 05ef724 commit 1edcc34

File tree

10 files changed

+32
-1200
lines changed

10 files changed

+32
-1200
lines changed

src/agent/legacy_schedule.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,22 @@ impl LegacySchedule {
6565

6666
let market_time = when_market_local.time();
6767

68-
let ret = match market_weekday {
68+
match market_weekday {
6969
Weekday::Mon => self.mon.can_publish_at(market_time),
7070
Weekday::Tue => self.tue.can_publish_at(market_time),
7171
Weekday::Wed => self.wed.can_publish_at(market_time),
7272
Weekday::Thu => self.thu.can_publish_at(market_time),
7373
Weekday::Fri => self.fri.can_publish_at(market_time),
7474
Weekday::Sat => self.sat.can_publish_at(market_time),
7575
Weekday::Sun => self.sun.can_publish_at(market_time),
76-
};
77-
78-
ret
76+
}
7977
}
8078
}
8179

8280
impl FromStr for LegacySchedule {
8381
type Err = anyhow::Error;
8482
fn from_str(s: &str) -> Result<Self> {
85-
let mut split_by_commas = s.split(",");
83+
let mut split_by_commas = s.split(',');
8684

8785
// Timezone id, e.g. Europe/Paris
8886
let tz_str = split_by_commas.next().ok_or(anyhow!(
@@ -195,7 +193,7 @@ impl FromStr for MHKind {
195193
"O" => Ok(MHKind::Open),
196194
"C" => Ok(MHKind::Closed),
197195
other => {
198-
let (start_str, end_str) = other.split_once("-").ok_or(anyhow!(
196+
let (start_str, end_str) = other.split_once('-').ok_or(anyhow!(
199197
"Missing '-' delimiter between start and end of range"
200198
))?;
201199

@@ -207,7 +205,7 @@ impl FromStr for MHKind {
207205
// the next best thing - see MAX_TIME_INSTANT for
208206
// details.
209207
let end = if end_str.contains("24:00") {
210-
MAX_TIME_INSTANT.clone()
208+
*MAX_TIME_INSTANT
211209
} else {
212210
NaiveTime::parse_from_str(end_str, "%H:%M")
213211
.context("end time does not match HH:MM format")?

src/agent/market_schedule.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl Display for ScheduleDayKind {
240240
}
241241
}
242242

243-
fn time_parser<'s>(input: &mut &'s str) -> PResult<NaiveTime> {
243+
fn time_parser(input: &mut &str) -> PResult<NaiveTime> {
244244
alt(("2400", take(4usize)))
245245
.verify_map(|time_str| match time_str {
246246
"2400" => Some(MAX_TIME_INSTANT),
@@ -249,7 +249,7 @@ fn time_parser<'s>(input: &mut &'s str) -> PResult<NaiveTime> {
249249
.parse_next(input)
250250
}
251251

252-
fn time_range_parser<'s>(input: &mut &'s str) -> PResult<RangeInclusive<NaiveTime>> {
252+
fn time_range_parser(input: &mut &str) -> PResult<RangeInclusive<NaiveTime>> {
253253
seq!(
254254
time_parser,
255255
_: "-",
@@ -259,7 +259,7 @@ fn time_range_parser<'s>(input: &mut &'s str) -> PResult<RangeInclusive<NaiveTim
259259
.parse_next(input)
260260
}
261261

262-
fn schedule_day_kind_parser<'s>(input: &mut &'s str) -> PResult<ScheduleDayKind> {
262+
fn schedule_day_kind_parser(input: &mut &str) -> PResult<ScheduleDayKind> {
263263
alt((
264264
"C".map(|_| ScheduleDayKind::Closed),
265265
"O".map(|_| ScheduleDayKind::Open),
@@ -350,7 +350,7 @@ mod tests {
350350
fn test_parsing_holiday_day_schedule() -> Result<()> {
351351
let input = "0412/O";
352352
let expected = HolidayDaySchedule {
353-
month: 04,
353+
month: 4,
354354
day: 12,
355355
kind: ScheduleDayKind::Open,
356356
};
@@ -360,7 +360,7 @@ mod tests {
360360

361361
let input = "0412/C";
362362
let expected = HolidayDaySchedule {
363-
month: 04,
363+
month: 4,
364364
day: 12,
365365
kind: ScheduleDayKind::Closed,
366366
};
@@ -369,7 +369,7 @@ mod tests {
369369

370370
let input = "0412/1234-1347";
371371
let expected = HolidayDaySchedule {
372-
month: 04,
372+
month: 4,
373373
day: 12,
374374
kind: ScheduleDayKind::TimeRanges(vec![
375375
NaiveTime::from_hms_opt(12, 34, 0).unwrap()
@@ -400,7 +400,7 @@ mod tests {
400400
..=NaiveTime::from_hms_opt(13, 47, 0).unwrap(),
401401
]),
402402
ScheduleDayKind::TimeRanges(vec![
403-
NaiveTime::from_hms_opt(09, 30, 0).unwrap()..=MAX_TIME_INSTANT,
403+
NaiveTime::from_hms_opt(9, 30, 0).unwrap()..=MAX_TIME_INSTANT,
404404
]),
405405
ScheduleDayKind::Closed,
406406
ScheduleDayKind::Closed,
@@ -409,17 +409,17 @@ mod tests {
409409
],
410410
holidays: vec![
411411
HolidayDaySchedule {
412-
month: 04,
412+
month: 4,
413413
day: 12,
414414
kind: ScheduleDayKind::Open,
415415
},
416416
HolidayDaySchedule {
417-
month: 04,
417+
month: 4,
418418
day: 13,
419419
kind: ScheduleDayKind::Closed,
420420
},
421421
HolidayDaySchedule {
422-
month: 04,
422+
month: 4,
423423
day: 14,
424424
kind: ScheduleDayKind::TimeRanges(vec![
425425
NaiveTime::from_hms_opt(12, 34, 0).unwrap()
@@ -430,7 +430,7 @@ mod tests {
430430
month: 12,
431431
day: 30,
432432
kind: ScheduleDayKind::TimeRanges(vec![
433-
NaiveTime::from_hms_opt(09, 30, 0).unwrap()..=MAX_TIME_INSTANT,
433+
NaiveTime::from_hms_opt(9, 30, 0).unwrap()..=MAX_TIME_INSTANT,
434434
]),
435435
},
436436
],

src/agent/services/exporter.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ mod exporter {
233233
if let Ok(publish_keypair) = get_publish_keypair(&*state, network, key_store.publish_keypair.as_ref()).await {
234234
if let Ok(permissioned_updates) = Exporter::get_permissioned_updates(
235235
&*state,
236-
network,
237236
&publish_keypair,
238237
config.exporter.staleness_threshold,
239238
config.exporter.unchanged_publish_threshold,
@@ -265,7 +264,6 @@ mod exporter {
265264
if let Ok(publish_keypair) = get_publish_keypair(&*state, network, key_store.publish_keypair.as_ref()).await {
266265
if let Err(err) = Exporter::update_recent_compute_unit_price(
267266
&*state,
268-
network,
269267
&publish_keypair,
270268
&client,
271269
config.exporter.staleness_threshold,

src/agent/services/oracle.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ where
102102
let client = PubsubClient::new(config.wss_url.as_str()).await?;
103103

104104
let (mut notifier, _unsub) = {
105-
let program_key = program_key;
106105
let commitment = config.oracle.commitment;
107106
let config = RpcProgramAccountsConfig {
108107
account_config: RpcAccountInfoConfig {
@@ -141,7 +140,7 @@ where
141140
}
142141

143142
tracing::debug!("Subscriber closed connection.");
144-
return Ok(());
143+
Ok(())
145144
}
146145

147146
/// On poll lookup all Pyth Mapping/Product/Price accounts and sync.

src/agent/solana.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
pub mod exporter;
2-
31
/// This module encapsulates all the interaction with a single Solana network:
42
/// - The Oracle, which reads data from the network
53
/// - The Exporter, which publishes data to the network

0 commit comments

Comments
 (0)