From d367944bf4ecbdfc66da0b678aac0e342b43499d Mon Sep 17 00:00:00 2001 From: benthecarman Date: Tue, 26 Mar 2024 16:19:15 -0500 Subject: [PATCH] Remove gateway cache --- src/lnurlp.rs | 2 +- src/mint.rs | 17 ++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/lnurlp.rs b/src/lnurlp.rs index 3feaf14..b3644ad 100644 --- a/src/lnurlp.rs +++ b/src/lnurlp.rs @@ -97,7 +97,7 @@ pub async fn lnurl_callback( let gateway = state .mm - .get_gateway(&federation_id) + .get_gateway(federation_id) .await .ok_or(anyhow!("Not gateway configured for federation"))?; diff --git a/src/mint.rs b/src/mint.rs index 37a94b7..fc27f0a 100644 --- a/src/mint.rs +++ b/src/mint.rs @@ -18,14 +18,12 @@ pub(crate) trait MultiMintWrapperTrait { async fn check_has_federation(&self, id: FederationId) -> bool; async fn get_federation_client(&self, id: FederationId) -> Option; async fn register_new_federation(&self, invite_code: InviteCode) -> anyhow::Result<()>; - async fn get_gateway(&self, id: &FederationId) -> Option; + async fn get_gateway(&self, id: FederationId) -> Option; } #[derive(Clone)] struct MultiMintWrapper { fm: Arc>, - /// Our preferred lightning gateway for each federation - gateways: Arc>>, } #[async_trait] @@ -57,18 +55,12 @@ impl MultiMintWrapperTrait for MultiMintWrapper { error!("Failed to update gateway cache: {e}"); } - if let Some(gateway) = select_gateway(&client).await { - self.gateways.write().await.insert(id, gateway); - } else { - error!("No suitable gateway found for federation {id}"); - } - Ok(()) } - async fn get_gateway(&self, id: &FederationId) -> Option { - let lock = self.gateways.read().await; - lock.get(id).cloned() + async fn get_gateway(&self, id: FederationId) -> Option { + let client = self.get_federation_client(id).await?; + select_gateway(&client).await } } @@ -101,7 +93,6 @@ pub(crate) async fn setup_multimint( let mmw = MultiMintWrapper { fm: Arc::new(RwLock::new(mm)), - gateways: Arc::new(RwLock::new(HashMap::new())), }; Ok(Arc::new(mmw))