|
@@ -7,6 +7,7 @@ use async_trait::async_trait;
|
|
use cdk_common::database::{Error, MintDatabase};
|
|
use cdk_common::database::{Error, MintDatabase};
|
|
use cdk_common::mint::MintKeySetInfo;
|
|
use cdk_common::mint::MintKeySetInfo;
|
|
use cdk_common::nut00::ProofsMethods;
|
|
use cdk_common::nut00::ProofsMethods;
|
|
|
|
+use cdk_common::MintInfo;
|
|
use tokio::sync::{Mutex, RwLock};
|
|
use tokio::sync::{Mutex, RwLock};
|
|
use uuid::Uuid;
|
|
use uuid::Uuid;
|
|
|
|
|
|
@@ -33,6 +34,7 @@ pub struct MintMemoryDatabase {
|
|
blinded_signatures: Arc<RwLock<HashMap<[u8; 33], BlindSignature>>>,
|
|
blinded_signatures: Arc<RwLock<HashMap<[u8; 33], BlindSignature>>>,
|
|
quote_signatures: Arc<RwLock<HashMap<Uuid, Vec<BlindSignature>>>>,
|
|
quote_signatures: Arc<RwLock<HashMap<Uuid, Vec<BlindSignature>>>>,
|
|
melt_requests: Arc<RwLock<HashMap<Uuid, (MeltBolt11Request<Uuid>, LnKey)>>>,
|
|
melt_requests: Arc<RwLock<HashMap<Uuid, (MeltBolt11Request<Uuid>, LnKey)>>>,
|
|
|
|
+ mint_info: Arc<RwLock<MintInfo>>,
|
|
}
|
|
}
|
|
|
|
|
|
impl MintMemoryDatabase {
|
|
impl MintMemoryDatabase {
|
|
@@ -49,6 +51,7 @@ impl MintMemoryDatabase {
|
|
blinded_signatures: HashMap<[u8; 33], BlindSignature>,
|
|
blinded_signatures: HashMap<[u8; 33], BlindSignature>,
|
|
quote_signatures: HashMap<Uuid, Vec<BlindSignature>>,
|
|
quote_signatures: HashMap<Uuid, Vec<BlindSignature>>,
|
|
melt_request: Vec<(MeltBolt11Request<Uuid>, LnKey)>,
|
|
melt_request: Vec<(MeltBolt11Request<Uuid>, LnKey)>,
|
|
|
|
+ mint_info: MintInfo,
|
|
) -> Result<Self, Error> {
|
|
) -> Result<Self, Error> {
|
|
let mut proofs = HashMap::new();
|
|
let mut proofs = HashMap::new();
|
|
let mut proof_states = HashMap::new();
|
|
let mut proof_states = HashMap::new();
|
|
@@ -87,6 +90,7 @@ impl MintMemoryDatabase {
|
|
quote_proofs: Arc::new(Mutex::new(quote_proofs)),
|
|
quote_proofs: Arc::new(Mutex::new(quote_proofs)),
|
|
quote_signatures: Arc::new(RwLock::new(quote_signatures)),
|
|
quote_signatures: Arc::new(RwLock::new(quote_signatures)),
|
|
melt_requests: Arc::new(RwLock::new(melt_requests)),
|
|
melt_requests: Arc::new(RwLock::new(melt_requests)),
|
|
|
|
+ mint_info: Arc::new(RwLock::new(mint_info)),
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -412,4 +416,17 @@ impl MintDatabase for MintMemoryDatabase {
|
|
|
|
|
|
Ok(ys.get(quote_id).cloned().unwrap_or_default())
|
|
Ok(ys.get(quote_id).cloned().unwrap_or_default())
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ async fn set_mint_info(&self, mint_info: MintInfo) -> Result<(), Self::Err> {
|
|
|
|
+ let mut current_mint_info = self.mint_info.write().await;
|
|
|
|
+
|
|
|
|
+ *current_mint_info = mint_info;
|
|
|
|
+
|
|
|
|
+ Ok(())
|
|
|
|
+ }
|
|
|
|
+ async fn get_mint_info(&self) -> Result<MintInfo, Self::Err> {
|
|
|
|
+ let mint_info = self.mint_info.read().await;
|
|
|
|
+
|
|
|
|
+ Ok(mint_info.clone())
|
|
|
|
+ }
|
|
}
|
|
}
|