-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move utility functions to common crate (#615)
* chore: move utility functions to common crate * fix: cleanup * chore: move get previous proof * chore: cleanup dependencies
- Loading branch information
Showing
14 changed files
with
65 additions
and
77 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,16 @@ | ||
use std::io; | ||
|
||
use dotenvy::dotenv; | ||
use tracing::warn; | ||
|
||
/// Attempt to load in the local `.env` if present and set any environment | ||
/// variables specified inside of it. | ||
/// | ||
/// To keep things simple, any IO error we will treat as the file not existing | ||
/// and continue moving on without the `env` variables set. | ||
pub fn load_dotenvy_vars_if_present() { | ||
match dotenv() { | ||
Ok(_) | Err(dotenvy::Error::Io(io::Error { .. })) => (), | ||
Err(e) => warn!("Found local `.env` file but was unable to parse it! (err: {e})",), | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,22 @@ | ||
use std::fs::File; | ||
use std::path::PathBuf; | ||
|
||
use proof_gen::proof_types::GeneratedBlockProof; | ||
|
||
pub fn generate_block_proof_file_name(directory: &Option<&str>, block_height: u64) -> PathBuf { | ||
let mut path = PathBuf::from(directory.unwrap_or("")); | ||
path.push(format!("b{}.zkproof", block_height)); | ||
path | ||
} | ||
|
||
pub fn get_previous_proof(path: Option<PathBuf>) -> anyhow::Result<Option<GeneratedBlockProof>> { | ||
if path.is_none() { | ||
return Ok(None); | ||
} | ||
|
||
let path = path.unwrap(); | ||
let file = File::open(path)?; | ||
let des = &mut serde_json::Deserializer::from_reader(&file); | ||
let proof: GeneratedBlockProof = serde_path_to_error::deserialize(des)?; | ||
Ok(Some(proof)) | ||
} |
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
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
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 was deleted.
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