From 3c16657b1c2f4b720b0a3361606724419f8e9338 Mon Sep 17 00:00:00 2001 From: Michael Jeffrey Date: Fri, 10 May 2024 10:58:16 -0700 Subject: [PATCH] parse datetime reward_index --- reward_index/src/main.rs | 7 +------ reward_index/src/settings.rs | 7 ++++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/reward_index/src/main.rs b/reward_index/src/main.rs index 4c6d28ba8..6b8bca704 100644 --- a/reward_index/src/main.rs +++ b/reward_index/src/main.rs @@ -1,5 +1,4 @@ use anyhow::Result; -use chrono::{TimeZone, Utc}; use clap::Parser; use file_store::{ file_info_poller::LookbackBehavior, file_source, reward_manifest::RewardManifest, FileStore, @@ -82,11 +81,7 @@ impl Server { .state(pool.clone()) .store(file_store) .prefix(FileType::RewardManifest.to_string()) - .lookback(LookbackBehavior::StartAfter( - Utc.timestamp_opt(settings.start_after as i64, 0) - .single() - .unwrap(), - )) + .lookback(LookbackBehavior::StartAfter(settings.start_after)) .poll_duration(interval) .offset(interval * 2) .create() diff --git a/reward_index/src/settings.rs b/reward_index/src/settings.rs index 342850e3e..e41231059 100644 --- a/reward_index/src/settings.rs +++ b/reward_index/src/settings.rs @@ -1,3 +1,4 @@ +use chrono::{DateTime, Utc}; use config::{Config, Environment, File}; use humantime_serde::re::humantime; use serde::Deserialize; @@ -38,15 +39,15 @@ pub struct Settings { pub operation_fund_key: Option, pub unallocated_reward_entity_key: Option, #[serde(default = "default_start_after")] - pub start_after: u64, + pub start_after: DateTime, } fn default_interval() -> Duration { humantime::parse_duration("15 minutes").unwrap() } -fn default_start_after() -> u64 { - 0 +fn default_start_after() -> DateTime { + DateTime::UNIX_EPOCH } fn default_log() -> String {