-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Create tables on start up if not exists - Write all the database types and insertion statements - store blocks and transaction methods - update the init logic that populates finalized blocks - update the sync logic that populates beyond finalized block
- Loading branch information
Showing
10 changed files
with
617 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use std::time::SystemTime; | ||
|
||
use chrono::{DateTime, Utc}; | ||
|
||
/// Converts unix timestamp seconds into DateTime Strings | ||
/// Accepts a given `format` string or uses standard default. | ||
pub fn systemtime_to_string(system_time: SystemTime, format: Option<&str>) -> String { | ||
let date_format = format.unwrap_or("%Y-%m-%d %H:%M:%S"); | ||
let datetime_utc: DateTime<Utc> = system_time.into(); | ||
datetime_utc.format(date_format).to_string() | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use std::time::Duration; | ||
|
||
#[test] | ||
fn date_conversions() { | ||
// Time Zero | ||
assert_eq!( | ||
systemtime_to_string(SystemTime::UNIX_EPOCH, None), | ||
"1970-01-01 00:00:00" | ||
); | ||
|
||
// First Ethereum Block: https://etherscan.io/block/1 | ||
assert_eq!( | ||
systemtime_to_string( | ||
SystemTime::UNIX_EPOCH + Duration::from_secs(1438262788), | ||
None | ||
), | ||
"2015-07-30 13:26:28" | ||
); | ||
|
||
// Different Formats | ||
assert_eq!( | ||
systemtime_to_string( | ||
SystemTime::UNIX_EPOCH, | ||
Some("Date(%Y-%m-%d)-Time(%H:%M:%S)") | ||
), | ||
"Date(1970-01-01)-Time(00:00:00)" | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.