refactor: check if token is pending during verification

This commit is contained in:
thesimplekid
2024-01-03 10:28:41 +00:00
parent d2118a18c2
commit b0a8d6046d

View File

@@ -36,6 +36,8 @@ pub enum Error {
DuplicateProofs,
#[error("Token Spent")]
TokenSpent,
#[error("Token Pending")]
TokenPending,
#[error("`{0}`")]
Custom(String),
#[error("`{0}`")]
@@ -271,13 +273,21 @@ impl<L: LocalStore> Mint<L> {
if self
.localstore
.get_spent_proof(&proof.secret)
.await
.unwrap()
.await?
.is_some()
{
return Err(Error::TokenSpent);
}
if self
.localstore
.get_pending_proof(&proof.secret)
.await?
.is_some()
{
return Err(Error::TokenPending);
}
let keyset = self
.localstore
.get_keyset(&proof.keyset_id)