Browse Source

feat: remove unused db fns

thesimplekid 8 months ago
parent
commit
9789475686

+ 0 - 52
crates/cdk-redb/src/mint/mod.rs

@@ -542,32 +542,6 @@ impl MintDatabase for MintRedbDatabase {
         Ok(proofs)
     }
 
-    async fn get_spent_proofs_by_secrets(
-        &self,
-        secrets: &[Secret],
-    ) -> Result<Vec<Option<Proof>>, Self::Err> {
-        let db = self.db.lock().await;
-        let read_txn = db.begin_read().map_err(Error::from)?;
-        let table = read_txn
-            .open_table(SPENT_PROOFS_TABLE)
-            .map_err(Error::from)?;
-
-        let mut proofs = Vec::with_capacity(secrets.len());
-
-        for secret in secrets {
-            let y: PublicKey = hash_to_curve(&secret.to_bytes())?;
-
-            match table.get(y.to_bytes()).map_err(Error::from)? {
-                Some(proof) => proofs.push(Some(
-                    serde_json::from_str(proof.value()).map_err(Error::from)?,
-                )),
-                None => proofs.push(None),
-            }
-        }
-
-        Ok(proofs)
-    }
-
     async fn add_pending_proofs(&self, proofs: Vec<Proof>) -> Result<(), Self::Err> {
         let db = self.db.lock().await;
 
@@ -615,32 +589,6 @@ impl MintDatabase for MintRedbDatabase {
         Ok(proofs)
     }
 
-    async fn get_pending_proofs_by_secrets(
-        &self,
-        secrets: &[Secret],
-    ) -> Result<Vec<Option<Proof>>, Self::Err> {
-        let db = self.db.lock().await;
-        let read_txn = db.begin_read().map_err(Error::from)?;
-        let table = read_txn
-            .open_table(PENDING_PROOFS_TABLE)
-            .map_err(Error::from)?;
-
-        let mut proofs = Vec::with_capacity(secrets.len());
-
-        for secret in secrets {
-            let y: PublicKey = hash_to_curve(&secret.to_bytes())?;
-
-            match table.get(y.to_bytes()).map_err(Error::from)? {
-                Some(proof) => proofs.push(Some(
-                    serde_json::from_str(proof.value()).map_err(Error::from)?,
-                )),
-                None => proofs.push(None),
-            }
-        }
-
-        Ok(proofs)
-    }
-
     async fn remove_pending_proofs(&self, secrets: Vec<&Secret>) -> Result<(), Self::Err> {
         let db = self.db.lock().await;
 

+ 0 - 68
crates/cdk-sqlite/src/mint/mod.rs

@@ -505,41 +505,6 @@ VALUES (?, ?, ?, ?, ?, ?, ?);
         transaction.commit().await.map_err(Error::from)?;
         Ok(())
     }
-    async fn get_spent_proofs_by_secrets(
-        &self,
-        secrets: &[Secret],
-    ) -> Result<Vec<Option<Proof>>, Self::Err> {
-        let mut transaction = self.pool.begin().await.map_err(Error::from)?;
-
-        let mut proofs = Vec::with_capacity(secrets.len());
-
-        for secret in secrets {
-            let rec = sqlx::query(
-                r#"
-SELECT *
-FROM proof
-WHERE secret=?
-AND state="SPENT";
-        "#,
-            )
-            .bind(secret.to_string())
-            .fetch_one(&mut transaction)
-            .await;
-
-            match rec {
-                Ok(rec) => {
-                    proofs.push(Some(sqlite_row_to_proof(rec)?));
-                }
-                Err(err) => match err {
-                    sqlx::Error::RowNotFound => proofs.push(None),
-                    _ => return Err(Error::SQLX(err).into()),
-                },
-            };
-        }
-        transaction.commit().await.map_err(Error::from)?;
-
-        Ok(proofs)
-    }
     async fn get_spent_proofs_by_ys(
         &self,
         ys: &[PublicKey],
@@ -601,39 +566,6 @@ VALUES (?, ?, ?, ?, ?, ?, ?);
 
         Ok(())
     }
-    async fn get_pending_proofs_by_secrets(
-        &self,
-        secrets: &[Secret],
-    ) -> Result<Vec<Option<Proof>>, Self::Err> {
-        let mut transaction = self.pool.begin().await.map_err(Error::from)?;
-
-        let mut proofs = Vec::with_capacity(secrets.len());
-
-        for secret in secrets {
-            let rec = sqlx::query(
-                r#"
-SELECT *
-FROM proof
-WHERE secret=?
-AND state="PENDING";
-        "#,
-            )
-            .bind(secret.to_string())
-            .fetch_one(&mut transaction)
-            .await;
-            match rec {
-                Ok(rec) => {
-                    proofs.push(Some(sqlite_row_to_proof(rec)?));
-                }
-                Err(err) => match err {
-                    sqlx::Error::RowNotFound => proofs.push(None),
-                    _ => return Err(Error::SQLX(err).into()),
-                },
-            };
-        }
-        transaction.commit().await.map_err(Error::from)?;
-        Ok(proofs)
-    }
     async fn get_pending_proofs_by_ys(
         &self,
         ys: &[PublicKey],

+ 0 - 38
crates/cdk/src/cdk_database/mint_memory.rs

@@ -223,25 +223,6 @@ impl MintDatabase for MintMemoryDatabase {
         Ok(())
     }
 
-    async fn get_spent_proofs_by_secrets(
-        &self,
-        secrets: &[Secret],
-    ) -> Result<Vec<Option<Proof>>, Self::Err> {
-        let spent_proofs = self.spent_proofs.read().await;
-
-        let mut proofs = Vec::with_capacity(secrets.len());
-
-        for secret in secrets {
-            let y = hash_to_curve(&secret.to_bytes())?;
-
-            let proof = spent_proofs.get(&y.to_bytes()).cloned();
-
-            proofs.push(proof);
-        }
-
-        Ok(proofs)
-    }
-
     async fn get_spent_proofs_by_ys(
         &self,
         ys: &[PublicKey],
@@ -268,25 +249,6 @@ impl MintDatabase for MintMemoryDatabase {
         Ok(())
     }
 
-    async fn get_pending_proofs_by_secrets(
-        &self,
-        secrets: &[Secret],
-    ) -> Result<Vec<Option<Proof>>, Self::Err> {
-        let spent_proofs = self.pending_proofs.read().await;
-
-        let mut proofs = Vec::with_capacity(secrets.len());
-
-        for secret in secrets {
-            let y = hash_to_curve(&secret.to_bytes())?;
-
-            let proof = spent_proofs.get(&y.to_bytes()).cloned();
-
-            proofs.push(proof);
-        }
-
-        Ok(proofs)
-    }
-
     async fn get_pending_proofs_by_ys(
         &self,
         ys: &[PublicKey],

+ 0 - 10
crates/cdk/src/cdk_database/mod.rs

@@ -219,11 +219,6 @@ pub trait MintDatabase {
 
     /// Add spent [`Proofs`]
     async fn add_spent_proofs(&self, proof: Proofs) -> Result<(), Self::Err>;
-    /// Get spent [`Proofs`] by secrets
-    async fn get_spent_proofs_by_secrets(
-        &self,
-        secret: &[Secret],
-    ) -> Result<Vec<Option<Proof>>, Self::Err>;
     /// Get spent [`Proofs`] by ys
     async fn get_spent_proofs_by_ys(
         &self,
@@ -232,11 +227,6 @@ pub trait MintDatabase {
 
     /// Add pending [`Proofs`]
     async fn add_pending_proofs(&self, proof: Proofs) -> Result<(), Self::Err>;
-    /// Get pending [`Proofs`] by secrets
-    async fn get_pending_proofs_by_secrets(
-        &self,
-        secrets: &[Secret],
-    ) -> Result<Vec<Option<Proof>>, Self::Err>;
     /// Get pending [`Proofs`] by ys
     async fn get_pending_proofs_by_ys(
         &self,