Skip to content

Commit

Permalink
More tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
octol committed Jan 17, 2025
1 parent 46b6ba0 commit cb12faa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,18 @@ async fn import_zk_nym(
.get_partial_verification_keys(shares.epoch_id, vpn_api_client)
.await?;

let master_vk = credential_storage
let master_vk = if let Some(stored_master_vk) = credential_storage
.get_master_verification_key(shares.epoch_id)
.await
.map_err(|err| RequestZkNymError::CredentialStorage(err.to_string()))?
.ok_or(RequestZkNymError::NoMasterVerificationKeyInStorage)?;
{
stored_master_vk
} else {
tracing::error!("No master verification key in storage");
// TODO: implement fetching the missing master verification key from nym-vpn-api.
// As of writing this, that endpoint does not yet exist.
return Err(RequestZkNymError::NoMasterVerificationKeyInStorage);
};

let ticketbook_type = response
.ticketbook_type
Expand All @@ -694,18 +701,29 @@ async fn import_zk_nym(
.await?;

// Check that we have the signatures we need to import
// TODO: fetch them if we don't
let _ = credential_storage
if credential_storage
.get_coin_index_signatures(shares.epoch_id)
.await
.map_err(|err| RequestZkNymError::CredentialStorage(err.to_string()))?
.ok_or(RequestZkNymError::NoCoinIndexSignaturesInStorage)?;
.is_none()
{
tracing::error!("No coin index signatures in storage");
// TODO: implement fetching the missing signatures from nym-vpn-api. As of writing this,
// that endpoint does not yet exist.
return Err(RequestZkNymError::NoCoinIndexSignaturesInStorage);
}

let _ = credential_storage
if credential_storage
.get_expiration_date_signatures(pending_request.expiration_date)
.await
.map_err(|err| RequestZkNymError::CredentialStorage(err.to_string()))?
.ok_or(RequestZkNymError::NoExpirationDateSignaturesInStorage)?;
.is_none()
{
tracing::error!("No expiration date signatures in storage");
// TODO: implement fetching the missing signatures from nym-vpn-api. As of writing this,
// that endpoint does not yet exist.
return Err(RequestZkNymError::NoExpirationDateSignaturesInStorage);
}

tracing::info!("Inserting issued ticketbook");
credential_storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ use crate::{error::Error, AvailableTicketbooks};
#[derive(Clone)]
pub(crate) struct VpnCredentialStorage {
data_dir: PathBuf,

credential_storage: PersistentCredentialStorage,

pending_requests_storage: PendingCredentialRequestsStorage,
}

Expand Down Expand Up @@ -214,9 +212,6 @@ impl VpnCredentialStorage {
pub(crate) async fn insert_pending_request(
&self,
pending_request: PendingCredentialRequest,
//id: &str,
//expiration_date: Date,
//request_info: &RequestInfo,
) -> Result<(), Error> {
self.pending_requests_storage
.insert_pending_request(pending_request)
Expand Down

0 comments on commit cb12faa

Please sign in to comment.