mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-23 05:56:02 +01:00
Fixed race condition
Bug: https://github.com/cashubtc/cdk/actions/runs/15683152414/job/44190084378?pr=822#step:5:19212 Reason: a race condition between removing proofs while melting and the quote states being updated. Solution: 1. Error on duplicate proofs 2. Read quote when updating to avoid race conditions and rollbacks Real solution: A transaction trait in the storage layer. That is coming next
This commit is contained in:
@@ -9,6 +9,10 @@ pub enum Error {
|
||||
#[error(transparent)]
|
||||
Sqlite(#[from] rusqlite::Error),
|
||||
|
||||
/// Duplicate entry
|
||||
#[error("Record already exists")]
|
||||
Duplicate,
|
||||
|
||||
/// Pool error
|
||||
#[error(transparent)]
|
||||
Pool(#[from] crate::pool::Error<rusqlite::Error>),
|
||||
@@ -98,6 +102,9 @@ pub enum Error {
|
||||
|
||||
impl From<Error> for cdk_common::database::Error {
|
||||
fn from(e: Error) -> Self {
|
||||
Self::Database(Box::new(e))
|
||||
match e {
|
||||
Error::Duplicate => Self::Duplicate,
|
||||
e => Self::Database(Box::new(e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user