Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove warnings #129

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/agent/legacy_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,22 @@ impl LegacySchedule {

let market_time = when_market_local.time();

let ret = match market_weekday {
match market_weekday {
Weekday::Mon => self.mon.can_publish_at(market_time),
Weekday::Tue => self.tue.can_publish_at(market_time),
Weekday::Wed => self.wed.can_publish_at(market_time),
Weekday::Thu => self.thu.can_publish_at(market_time),
Weekday::Fri => self.fri.can_publish_at(market_time),
Weekday::Sat => self.sat.can_publish_at(market_time),
Weekday::Sun => self.sun.can_publish_at(market_time),
};

ret
}
}
}

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

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

Expand All @@ -207,7 +205,7 @@ impl FromStr for MHKind {
// the next best thing - see MAX_TIME_INSTANT for
// details.
let end = if end_str.contains("24:00") {
MAX_TIME_INSTANT.clone()
*MAX_TIME_INSTANT
} else {
NaiveTime::parse_from_str(end_str, "%H:%M")
.context("end time does not match HH:MM format")?
Expand Down
22 changes: 11 additions & 11 deletions src/agent/market_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl Display for ScheduleDayKind {
}
}

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

fn time_range_parser<'s>(input: &mut &'s str) -> PResult<RangeInclusive<NaiveTime>> {
fn time_range_parser(input: &mut &str) -> PResult<RangeInclusive<NaiveTime>> {
seq!(
time_parser,
_: "-",
Expand All @@ -259,7 +259,7 @@ fn time_range_parser<'s>(input: &mut &'s str) -> PResult<RangeInclusive<NaiveTim
.parse_next(input)
}

fn schedule_day_kind_parser<'s>(input: &mut &'s str) -> PResult<ScheduleDayKind> {
fn schedule_day_kind_parser(input: &mut &str) -> PResult<ScheduleDayKind> {
alt((
"C".map(|_| ScheduleDayKind::Closed),
"O".map(|_| ScheduleDayKind::Open),
Expand Down Expand Up @@ -350,7 +350,7 @@ mod tests {
fn test_parsing_holiday_day_schedule() -> Result<()> {
let input = "0412/O";
let expected = HolidayDaySchedule {
month: 04,
month: 4,
day: 12,
kind: ScheduleDayKind::Open,
};
Expand All @@ -360,7 +360,7 @@ mod tests {

let input = "0412/C";
let expected = HolidayDaySchedule {
month: 04,
month: 4,
day: 12,
kind: ScheduleDayKind::Closed,
};
Expand All @@ -369,7 +369,7 @@ mod tests {

let input = "0412/1234-1347";
let expected = HolidayDaySchedule {
month: 04,
month: 4,
day: 12,
kind: ScheduleDayKind::TimeRanges(vec![
NaiveTime::from_hms_opt(12, 34, 0).unwrap()
Expand Down Expand Up @@ -400,7 +400,7 @@ mod tests {
..=NaiveTime::from_hms_opt(13, 47, 0).unwrap(),
]),
ScheduleDayKind::TimeRanges(vec![
NaiveTime::from_hms_opt(09, 30, 0).unwrap()..=MAX_TIME_INSTANT,
NaiveTime::from_hms_opt(9, 30, 0).unwrap()..=MAX_TIME_INSTANT,
]),
ScheduleDayKind::Closed,
ScheduleDayKind::Closed,
Expand All @@ -409,17 +409,17 @@ mod tests {
],
holidays: vec![
HolidayDaySchedule {
month: 04,
month: 4,
day: 12,
kind: ScheduleDayKind::Open,
},
HolidayDaySchedule {
month: 04,
month: 4,
day: 13,
kind: ScheduleDayKind::Closed,
},
HolidayDaySchedule {
month: 04,
month: 4,
day: 14,
kind: ScheduleDayKind::TimeRanges(vec![
NaiveTime::from_hms_opt(12, 34, 0).unwrap()
Expand All @@ -430,7 +430,7 @@ mod tests {
month: 12,
day: 30,
kind: ScheduleDayKind::TimeRanges(vec![
NaiveTime::from_hms_opt(09, 30, 0).unwrap()..=MAX_TIME_INSTANT,
NaiveTime::from_hms_opt(9, 30, 0).unwrap()..=MAX_TIME_INSTANT,
]),
},
],
Expand Down
2 changes: 0 additions & 2 deletions src/agent/services/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ mod exporter {
if let Ok(publish_keypair) = get_publish_keypair(&*state, network, key_store.publish_keypair.as_ref()).await {
if let Ok(permissioned_updates) = Exporter::get_permissioned_updates(
&*state,
network,
&publish_keypair,
config.exporter.staleness_threshold,
config.exporter.unchanged_publish_threshold,
Expand Down Expand Up @@ -265,7 +264,6 @@ mod exporter {
if let Ok(publish_keypair) = get_publish_keypair(&*state, network, key_store.publish_keypair.as_ref()).await {
if let Err(err) = Exporter::update_recent_compute_unit_price(
&*state,
network,
&publish_keypair,
&client,
config.exporter.staleness_threshold,
Expand Down
3 changes: 1 addition & 2 deletions src/agent/services/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ where
let client = PubsubClient::new(config.wss_url.as_str()).await?;

let (mut notifier, _unsub) = {
let program_key = program_key;
let commitment = config.oracle.commitment;
let config = RpcProgramAccountsConfig {
account_config: RpcAccountInfoConfig {
Expand Down Expand Up @@ -141,7 +140,7 @@ where
}

tracing::debug!("Subscriber closed connection.");
return Ok(());
Ok(())
}

/// On poll lookup all Pyth Mapping/Product/Price accounts and sync.
Expand Down
2 changes: 0 additions & 2 deletions src/agent/solana.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pub mod exporter;

/// This module encapsulates all the interaction with a single Solana network:
/// - The Oracle, which reads data from the network
/// - The Exporter, which publishes data to the network
Expand Down
Loading
Loading