refactor(wallet/database): get_proofs returns Vec<ProofInfo> instead of Option<Vec<ProofInfo>>

This commit is contained in:
thesimplekid
2024-07-16 15:03:05 +01:00
parent e51f81f441
commit 4f240f3953
7 changed files with 117 additions and 122 deletions

View File

@@ -507,7 +507,7 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
unit: Option<CurrencyUnit>,
state: Option<Vec<State>>,
spending_conditions: Option<Vec<SpendingConditions>>,
) -> Result<Option<Vec<ProofInfo>>, Self::Err> {
) -> Result<Vec<ProofInfo>, Self::Err> {
let recs = sqlx::query(
r#"
SELECT *
@@ -520,13 +520,11 @@ FROM proof;
let recs = match recs {
Ok(rec) => rec,
Err(err) => match err {
sqlx::Error::RowNotFound => return Ok(None),
sqlx::Error::RowNotFound => return Ok(vec![]),
_ => return Err(Error::SQLX(err).into()),
},
};
tracing::debug!("{}", recs.len());
let proofs: Vec<ProofInfo> = recs
.iter()
.filter_map(|p| match sqlite_row_to_proof_info(p) {
@@ -547,11 +545,10 @@ FROM proof;
}
})
.collect();
tracing::debug!("{}", proofs.len());
match proofs.is_empty() {
false => Ok(Some(proofs)),
true => return Ok(None),
false => Ok(proofs),
true => return Ok(vec![]),
}
}
async fn remove_proofs(&self, proofs: &Proofs) -> Result<(), Self::Err> {