mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-21 22:54:49 +01:00
refactor(wallet/database): get_proofs returns Vec<ProofInfo> instead of Option<Vec<ProofInfo>>
This commit is contained in:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user