Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Check if storage is working when returning the response to a faucet h…
Browse files Browse the repository at this point in the history
…ealthcheck request. (#1189)
  • Loading branch information
philippecamacho authored Jun 30, 2022
1 parent 8db87bd commit 8971a97
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/rust/src/bin/gen-vk-libraries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::{fs::OpenOptions, io::prelude::*, path::PathBuf};

// depth of the record merkle tree
const TREE_DEPTH: u8 = 24;
// list of supported tranaction types, each would result in a different verifying key
// list of supported transaction types, each would result in a different verifying key
const SUPPORTED_VKS: [(NoteType, u8, u8, u8); 7] = [
(NoteType::Transfer, 1, 2, TREE_DEPTH),
(NoteType::Transfer, 2, 2, TREE_DEPTH),
Expand Down
22 changes: 22 additions & 0 deletions faucet/src/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,28 @@ pub struct HealthCheck {
/// normally, a response with status 503 and payload {"status":
/// "unavailable"} should be added.
async fn healthcheck(req: tide::Request<FaucetState>) -> Result<tide::Response, tide::Error> {
// Ensure we can write to storage.
let mut index = req.state().queue.index.lock().await;
let default_user_pub_key = UserPubKey::default();
let res = index.insert(default_user_pub_key.clone());
if res.is_err() {
tracing::error!(
"Insertion of dummy public key into faucet queue index failed. {:?}",
res
);
return Err(faucet_server_error(res.err().unwrap()));
}

let res = index.remove(&default_user_pub_key);
if res.is_err() {
tracing::error!(
"Removal of dummy public key from faucet queue index failed. {:?}",
res
);
return Err(faucet_server_error(res.err().unwrap()));
}

// Return healthcheck response
response(
&req,
&HealthCheck {
Expand Down

0 comments on commit 8971a97

Please sign in to comment.