Skip to content

Commit

Permalink
Merge pull request #2 from sausaging/test-async
Browse files Browse the repository at this point in the history
fixes in ping endpoint
  • Loading branch information
manojkgorle authored Mar 26, 2024
2 parents 8be6965 + 29e1778 commit 256f059
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub async fn process_verification_queue(
_sp1_hashmap: Arc<Mutex<HashMap<String, Sp1Proof>>>,
_risc0_hashmap: Arc<Mutex<HashMap<String, Risc0Proof>>>,
_miden_hashmap: Arc<Mutex<HashMap<String, MidenProof>>>,
current_port: Arc<Mutex<u16>>,
current_port: Arc<Mutex<u32>>,
) {
loop {
let mut queue = queue.lock().await;
Expand Down
4 changes: 2 additions & 2 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ pub struct Proof {
#[derive(Serialize)]
pub struct Ping {
pub success: bool,
pub instantiated_port: u16,
pub uninstantiated_port: u16,
pub rust_port: String,
pub uinit_port: String,
}

#[derive(Serialize, Debug)]
Expand Down
8 changes: 4 additions & 4 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ async fn hello() -> impl Responder {

#[get("/ping")]
async fn ping(
current_port: web::Data<Arc<Mutex<u16>>>,
current_port: web::Data<Arc<Mutex<u32>>>,
instantiated_ports: web::Data<Arc<Mutex<Vec<u16>>>>,
uninstantiated_ports: web::Data<Arc<Mutex<Vec<u16>>>>,
uninstantiated_ports: web::Data<Arc<Mutex<Vec<u32>>>>,
) -> impl Responder {
// will instantiate a new port here on every ping call and return the port number
let mut instantiated_ports = instantiated_ports.lock().await;
Expand All @@ -28,8 +28,8 @@ async fn ping(
*current_port = uninstantiated_port;
HttpResponse::Ok().json(Ping {
success: true,
instantiated_port,
uninstantiated_port: *current_port,
rust_port: instantiated_port.to_string(),
uinit_port: current_port.to_string(),
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ lazy_static! {
Arc::new(Mutex::new(VecDeque::new()));
pub static ref INSTANTIATED_PORTS: Arc<Mutex<Vec<u16>>> =
Arc::new(Mutex::new(Vec::from(vec![8081, 8082, 8083, 8084, 8085])));
pub static ref UNINSTANTIATED_PORTS: Arc<Mutex<Vec<u16>>> =
pub static ref UNINSTANTIATED_PORTS: Arc<Mutex<Vec<u32>>> =
Arc::new(Mutex::new(Vec::from(vec![8086, 8087, 8088, 8089, 8090])));
pub static ref CURRENT_PORT: Arc<Mutex<u16>> = Arc::new(Mutex::new(0));
pub static ref CURRENT_PORT: Arc<Mutex<u32>> = Arc::new(Mutex::new(0));
}

0 comments on commit 256f059

Please sign in to comment.