|
@@ -47,12 +47,6 @@ pub(super) struct SharedWorker {
|
|
|
/// Mint URL
|
|
/// Mint URL
|
|
|
pub(super) mint_url: MintUrl,
|
|
pub(super) mint_url: MintUrl,
|
|
|
|
|
|
|
|
- /// Client for HTTP requests (shared across all instances)
|
|
|
|
|
- pub(super) client: Arc<dyn MintConnector + Send + Sync>,
|
|
|
|
|
-
|
|
|
|
|
- #[cfg(feature = "auth")]
|
|
|
|
|
- pub(super) auth_client: Arc<dyn AuthMintConnector + Send + Sync>,
|
|
|
|
|
-
|
|
|
|
|
/// All storages registered for this mint
|
|
/// All storages registered for this mint
|
|
|
pub(super) storages: StorageList,
|
|
pub(super) storages: StorageList,
|
|
|
|
|
|
|
@@ -181,7 +175,7 @@ async fn load_cache_from_storages(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Collect unique keys from all storages
|
|
// Collect unique keys from all storages
|
|
|
- for (id, _keyset_info) in &cache.keysets_by_id {
|
|
|
|
|
|
|
+ for id in cache.keysets_by_id.keys() {
|
|
|
if !cache.keys_by_id.contains_key(id) {
|
|
if !cache.keys_by_id.contains_key(id) {
|
|
|
if let Some(keys) = storage.get_keys(id).await? {
|
|
if let Some(keys) = storage.get_keys(id).await? {
|
|
|
cache.keys_by_id.insert(*id, Arc::new(keys));
|
|
cache.keys_by_id.insert(*id, Arc::new(keys));
|
|
@@ -260,13 +254,15 @@ async fn write_cache_to_storage(
|
|
|
let _ = storage
|
|
let _ = storage
|
|
|
.add_mint(mint_url.clone(), Some(mint_info.clone()))
|
|
.add_mint(mint_url.clone(), Some(mint_info.clone()))
|
|
|
.await
|
|
.await
|
|
|
- .inspect_err(|e| {
|
|
|
|
|
- tracing::warn!("Failed to persist mint_info for {}: {}", mint_url, e)
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ .inspect_err(|e| tracing::warn!("Failed to persist mint_info for {}: {}", mint_url, e));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Write keysets
|
|
// Write keysets
|
|
|
- let keysets: Vec<_> = cache.keysets_by_id.values().map(|ks| (**ks).clone()).collect();
|
|
|
|
|
|
|
+ let keysets: Vec<_> = cache
|
|
|
|
|
+ .keysets_by_id
|
|
|
|
|
+ .values()
|
|
|
|
|
+ .map(|ks| (**ks).clone())
|
|
|
|
|
+ .collect();
|
|
|
let _ = storage
|
|
let _ = storage
|
|
|
.add_mint_keysets(mint_url.clone(), keysets)
|
|
.add_mint_keysets(mint_url.clone(), keysets)
|
|
|
.await
|
|
.await
|
|
@@ -378,15 +374,15 @@ pub(super) async fn fetch_mint_data_from_http(
|
|
|
|
|
|
|
|
// Load keyset keys (try database first, then HTTP)
|
|
// Load keyset keys (try database first, then HTTP)
|
|
|
if let Ok(keyset) = load_keyset_from_db_or_http(mint_url, client, storages, &keyset_info.id)
|
|
if let Ok(keyset) = load_keyset_from_db_or_http(mint_url, client, storages, &keyset_info.id)
|
|
|
- .await
|
|
|
|
|
- .inspect_err(|e| {
|
|
|
|
|
- tracing::warn!(
|
|
|
|
|
- "Failed to load keyset {} for {}: {}",
|
|
|
|
|
- keyset_info.id,
|
|
|
|
|
- mint_url,
|
|
|
|
|
- e
|
|
|
|
|
- )
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ .await
|
|
|
|
|
+ .inspect_err(|e| {
|
|
|
|
|
+ tracing::warn!(
|
|
|
|
|
+ "Failed to load keyset {} for {}: {}",
|
|
|
|
|
+ keyset_info.id,
|
|
|
|
|
+ mint_url,
|
|
|
|
|
+ e
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
{
|
|
{
|
|
|
new_cache
|
|
new_cache
|
|
|
.keys_by_id
|
|
.keys_by_id
|
|
@@ -487,6 +483,8 @@ pub(super) async fn refresh_loop(
|
|
|
cache.clone(),
|
|
cache.clone(),
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ println!("begin refresh_loop");
|
|
|
|
|
+
|
|
|
loop {
|
|
loop {
|
|
|
tokio::select! {
|
|
tokio::select! {
|
|
|
Some(msg) = rx.recv() => {
|
|
Some(msg) = rx.recv() => {
|
|
@@ -538,9 +536,12 @@ pub(super) async fn refresh_loop(
|
|
|
storages.clone(),
|
|
storages.clone(),
|
|
|
cache.clone(),
|
|
cache.clone(),
|
|
|
);
|
|
);
|
|
|
|
|
+ } else => {
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tracing::debug!("Refresh loop stopped for {}", mint_url);
|
|
tracing::debug!("Refresh loop stopped for {}", mint_url);
|
|
|
|
|
+ println!("end refresh_loop");
|
|
|
}
|
|
}
|