Skip to content

Commit 89dede2

Browse files
committed
Parallelize Cashu cache loading
Load independent mint and proof caches together so remote stores avoid an unnecessary sequential round trip during wallet startup.
1 parent 6bcb34c commit 89dede2

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

orange-sdk/src/trusted_wallet/cashu/cashu_store.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,20 @@ impl CashuKvDatabase {
180180
}
181181

182182
async fn load_caches(&self) -> Result<(), DatabaseError> {
183-
// Load mints cache
184-
if let Ok(mints) = self.load_mints_from_store().await {
183+
// These use independent namespaces and can be restored concurrently. This
184+
// lets remote stores pipeline the requests while synchronous stores retain
185+
// their existing behavior.
186+
let (mints, proofs) =
187+
tokio::join!(self.load_mints_from_store(), self.load_proofs_from_store());
188+
189+
if let Ok(mints) = mints {
185190
let mut cache = self.mints_cache.write().unwrap();
186191
*cache = mints;
187192
}
188193

189194
// Proof errors must not be hidden: presenting an empty cache for an unreadable
190195
// proof set could make the wallet report an incorrect balance.
191-
let proofs = self.load_proofs_from_store().await?;
196+
let proofs = proofs?;
192197
let mut cache = self.proofs_cache.write().unwrap();
193198
*cache = proofs;
194199

0 commit comments

Comments
 (0)