Skip to content

Commit

Permalink
Plain to enc dump conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay111meher committed Jan 2, 2025
1 parent 6443805 commit 9077689
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions matching_engine/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::fs;
use std::io;

use dotenv::dotenv;
use matching_engine::Dump;
use matching_engine::EncryptedDump;
use matching_engine::{MatchingEngine, MatchingEngineConfig};

Expand Down Expand Up @@ -31,13 +32,35 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
"../matching_engine_config/encrypted_dump.json",
"./matching_engine_config/encrypted_dump.json",
];

match read_file_from_paths(&encrypted_dump_paths) {
Ok(dump_content) => {
let enc_dump: EncryptedDump = serde_json::from_str(&dump_content)?;
matching_engine
.run_from_encrypted_dump(enc_dump, encrypted_dump_paths[1].to_string())
.await?;
}
Err(e) if e.kind() == io::ErrorKind::NotFound => {
// Handle the NotFound error case
let plain_dump = [
"../matching_engine_config/dump.json",
"./matching_engine_config/dump.json",
];

match read_file_from_paths(&plain_dump) {
Ok(dump_content) => {
let dump: Dump = serde_json::from_str(&dump_content)?;
matching_engine
.run_from_dump(dump, encrypted_dump_paths[1].to_string())
.await?;
}
Err(_) => {
matching_engine
.run(encrypted_dump_paths[1].to_string())
.await?;
}
}
}
Err(_) => {
matching_engine
.run(encrypted_dump_paths[1].to_string())
Expand Down

0 comments on commit 9077689

Please sign in to comment.