use async_trait::async_trait;
use cdk_common::database::DynMintDatabase;
use cdk_common::{Error, PublicKey, QuoteId};
use tracing::instrument;
use uuid::Uuid;
use crate::mint::subscription::PubSubManager;
#[async_trait]
pub trait CompensatingAction: Send + Sync {
async fn execute(&self, db: &DynMintDatabase, pubsub: &PubSubManager) -> Result<(), Error>;
fn name(&self) -> &'static str;
}
pub struct RemoveMeltSetup {
pub input_ys: Vec<PublicKey>,
pub blinded_secrets: Vec<PublicKey>,
pub quote_id: QuoteId,
pub operation_id: Uuid,
}
#[async_trait]
impl CompensatingAction for RemoveMeltSetup {
#[instrument(skip_all)]
async fn execute(&self, db: &DynMintDatabase, pubsub: &PubSubManager) -> Result<(), Error> {
tracing::info!(
"Compensation: Removing melt setup for quote {} ({} proofs, {} blinded messages, saga {})",
self.quote_id,
self.input_ys.len(),
self.blinded_secrets.len(),
self.operation_id
);
super::super::shared::rollback_melt_quote(
db,
pubsub,
&self.quote_id,
&self.input_ys,
&self.blinded_secrets,
&self.operation_id,
)
.await
}
fn name(&self) -> &'static str {
"RemoveMeltSetup"
}
}