mirror of
https://github.com/aljazceru/cdk.git
synced 2026-01-19 21:05:44 +01:00
* feat: add keyset u32 mapping migration and duplicate handling - Add new database migration (version 3) to include u32 representation for keysets - Implement migration for both redb and SQL databases - Add duplicate detection and handling for keyset entries - Create unique index constraint for keyset_u32 column in SQL - Update keyset storage to include u32 identifiers - Handle backwards compatibility for existing databases * chore: clippy * refactor(cashu): simplify keyset ID verification logic - Consolidate match expression into a single expression - Use direct comparison with ensure_cdk macro - Improve readability of keyset ID validation * refactor(cdk): rename `fetch_keyset_keys` to `load_keyset_keys` for clarity - Renamed `fetch_keyset_keys` to `load_keyset_keys` across multiple modules to better reflect its behavior of loading keys from local storage or fetching from mint when missing. - Added debug logging to indicate when keys are being fetched from the mint. - Simplified key loading logic in `update_mint_keysets` by removing redundant existence checks. * chore: remove unused vec
114 lines
2.8 KiB
Rust
114 lines
2.8 KiB
Rust
//! Redb Error
|
|
|
|
use std::num::ParseIntError;
|
|
|
|
use thiserror::Error;
|
|
|
|
/// Redb Database Error
|
|
#[derive(Debug, Error)]
|
|
pub enum Error {
|
|
/// Redb Error
|
|
#[error(transparent)]
|
|
Redb(#[from] Box<redb::Error>),
|
|
/// Redb Database Error
|
|
#[error(transparent)]
|
|
Database(#[from] Box<redb::DatabaseError>),
|
|
/// Redb Transaction Error
|
|
#[error(transparent)]
|
|
Transaction(#[from] Box<redb::TransactionError>),
|
|
/// Redb Commit Error
|
|
#[error(transparent)]
|
|
Commit(#[from] Box<redb::CommitError>),
|
|
/// Redb Table Error
|
|
#[error(transparent)]
|
|
Table(#[from] Box<redb::TableError>),
|
|
/// Redb Storage Error
|
|
#[error(transparent)]
|
|
Storage(#[from] Box<redb::StorageError>),
|
|
/// Serde Json Error
|
|
#[error(transparent)]
|
|
Serde(#[from] serde_json::Error),
|
|
/// Parse int Error
|
|
#[error(transparent)]
|
|
ParseInt(#[from] ParseIntError),
|
|
/// CDK Database Error
|
|
#[error(transparent)]
|
|
CDKDatabase(#[from] cdk_common::database::Error),
|
|
/// CDK Mint Url Error
|
|
#[error(transparent)]
|
|
CDKMintUrl(#[from] cdk_common::mint_url::Error),
|
|
/// CDK Error
|
|
#[error(transparent)]
|
|
CDK(#[from] cdk_common::error::Error),
|
|
/// NUT00 Error
|
|
#[error(transparent)]
|
|
CDKNUT00(#[from] cdk_common::nuts::nut00::Error),
|
|
/// NUT02 Error
|
|
#[error(transparent)]
|
|
CDKNUT02(#[from] cdk_common::nuts::nut02::Error),
|
|
/// DHKE Error
|
|
#[error(transparent)]
|
|
DHKE(#[from] cdk_common::dhke::Error),
|
|
/// Unknown Mint Info
|
|
#[error("Unknown mint info")]
|
|
UnknownMintInfo,
|
|
/// Unknown quote ttl
|
|
#[error("Unknown quote ttl")]
|
|
UnknownQuoteTTL,
|
|
/// Unknown Proof Y
|
|
#[error("Unknown proof Y")]
|
|
UnknownY,
|
|
/// Unknown Quote
|
|
#[error("Unknown quote")]
|
|
UnknownQuote,
|
|
/// Unknown Database Version
|
|
#[error("Unknown database version")]
|
|
UnknownDatabaseVersion,
|
|
/// Duplicate
|
|
#[error("Duplicate")]
|
|
Duplicate,
|
|
}
|
|
|
|
impl From<Error> for cdk_common::database::Error {
|
|
fn from(e: Error) -> Self {
|
|
Self::Database(Box::new(e))
|
|
}
|
|
}
|
|
|
|
// Implement From for boxed redb errors
|
|
impl From<redb::Error> for Error {
|
|
fn from(e: redb::Error) -> Self {
|
|
Self::Redb(Box::new(e))
|
|
}
|
|
}
|
|
|
|
impl From<redb::DatabaseError> for Error {
|
|
fn from(e: redb::DatabaseError) -> Self {
|
|
Self::Database(Box::new(e))
|
|
}
|
|
}
|
|
|
|
impl From<redb::TransactionError> for Error {
|
|
fn from(e: redb::TransactionError) -> Self {
|
|
Self::Transaction(Box::new(e))
|
|
}
|
|
}
|
|
|
|
impl From<redb::CommitError> for Error {
|
|
fn from(e: redb::CommitError) -> Self {
|
|
Self::Commit(Box::new(e))
|
|
}
|
|
}
|
|
|
|
impl From<redb::TableError> for Error {
|
|
fn from(e: redb::TableError) -> Self {
|
|
Self::Table(Box::new(e))
|
|
}
|
|
}
|
|
|
|
impl From<redb::StorageError> for Error {
|
|
fn from(e: redb::StorageError) -> Self {
|
|
Self::Storage(Box::new(e))
|
|
}
|
|
}
|