Browse Source

Merge pull request #601 from thesimplekid/reconnect_cln

fix: cln return error on stream
thesimplekid 1 month ago
parent
commit
2beb3f971c
2 changed files with 3 additions and 5 deletions
  1. 2 3
      crates/cdk-cln/src/lib.rs
  2. 1 2
      crates/cdk/src/mint/mod.rs

+ 2 - 3
crates/cdk-cln/src/lib.rs

@@ -8,7 +8,6 @@ use std::pin::Pin;
 use std::str::FromStr;
 use std::sync::atomic::{AtomicBool, Ordering};
 use std::sync::Arc;
-use std::time::Duration;
 
 use async_trait::async_trait;
 use cdk::amount::{to_unit, Amount, MSAT_IN_SAT};
@@ -162,8 +161,8 @@ impl MintLightning for Cln {
                                 }
                                 Err(e) => {
                                     tracing::warn!("Error fetching invoice: {e}");
-                                    tokio::time::sleep(Duration::from_secs(1)).await;
-                                    continue;
+                                    is_active.store(false, Ordering::SeqCst);
+                                    return None;
                                 }
                             }
                         }

+ 1 - 2
crates/cdk/src/mint/mod.rs

@@ -228,7 +228,6 @@ impl Mint {
                 let shutdown = Arc::clone(&shutdown);
                 let key = key.clone();
                 join_set.spawn(async move {
-            if !ln.is_wait_invoice_active() {
             loop {
                 tokio::select! {
                     _ = shutdown.notified() => {
@@ -247,12 +246,12 @@ impl Mint {
                             }
                             Err(err) => {
                                 tracing::warn!("Could not get invoice stream for {:?}: {}",key, err);
+
                                 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
                             }
                         }
                     }
                     }
-                }
             }
         });
             }