From 9135febd0283d074133d085dac48ca037d43a394 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Mon, 15 Jan 2024 20:38:50 +0000 Subject: [PATCH] refactor: send sync on localstore --- crates/cashu-sdk/src/mint/mod.rs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/cashu-sdk/src/mint/mod.rs b/crates/cashu-sdk/src/mint/mod.rs index 0d7e25d9..8aeb4339 100644 --- a/crates/cashu-sdk/src/mint/mod.rs +++ b/crates/cashu-sdk/src/mint/mod.rs @@ -1,4 +1,5 @@ use std::collections::HashSet; +use std::sync::Arc; use cashu::dhke::{sign_message, verify_message}; #[cfg(feature = "nut07")] @@ -53,16 +54,16 @@ pub enum Error { MultipleUnits, } -pub struct Mint { +pub struct Mint { // pub pubkey: PublicKey mnemonic: Mnemonic, pub fee_reserve: FeeReserve, - pub localstore: L, + pub localstore: Arc, } -impl Mint { +impl Mint { pub async fn new( - localstore: L, + localstore: Arc, mnemonic: Mnemonic, keysets_info: HashSet, min_fee_reserve: Amount, @@ -111,6 +112,23 @@ impl Mint { Ok(quote) } + pub async fn update_mint_quote(&self, quote: MintQuote) -> Result<(), Error> { + self.localstore.add_mint_quote(quote).await?; + + Ok(()) + } + + pub async fn mint_quotes(&self) -> Result, Error> { + let quotes = self.localstore.get_mint_quotes().await?; + Ok(quotes) + } + + pub async fn remove_mint_quote(&self, quote_id: &str) -> Result<(), Error> { + self.localstore.remove_mint_quote(quote_id).await?; + + Ok(()) + } + pub async fn new_melt_quote( &self, request: String,