Skip to content

Commit

Permalink
fix: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tvolk131 committed Jun 14, 2024
1 parent 34ca07c commit 811d33e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion devimint/src/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 95,7 @@ use fedimint_core::envs::{
use fedimint_portalloc::port_alloc;
use fedimint_server::config::ConfigGenParams;
use fedimint_server::net::api::ApiSecrets;
use fedimintd::envs::{FM_FORCE_API_SECRETS_ENV, FM_PORT_ESPLORA_ENV};
use fedimintd::envs::FM_FORCE_API_SECRETS_ENV;
use format as f;

pub fn utf8(path: &Path) -> &str {
Expand Down
37 changes: 23 additions & 14 deletions gateway/ln-gateway/src/lightning/ldk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 4,7 @@ use std::time::Duration;

use async_trait::async_trait;
use bitcoin::{secp256k1, Network, OutPoint};
use fedimint_core::runtime::spawn;
use fedimint_core::task::TaskGroup;
use ldk_node::lightning::ln::msgs::SocketAddress;
use ldk_node::lightning::ln::PaymentHash;
Expand Down Expand Up @@ -63,6 64,7 @@ impl GatewayLdkClient {
node_builder.set_storage_dir_path(storage_dir_path);
}

// TODO: Replace `.build()` with `.build_with_store()`.
let node = node_builder.build()?;
node.start().map_err(|e| {
error!("Failed to start LDK Node: {e:?}");
Expand All @@ -74,19 76,22 @@ impl GatewayLdkClient {
let (htlc_stream_sender, htlc_stream_receiver) = tokio::sync::mpsc::channel(1024);

let node_clone = node.clone();
let task_handle = tokio::spawn(async move {
loop {
let node = node_clone.lock().await;
if Self::seed_route_htlcs_stream(&node, &htlc_stream_sender)
.await
.is_err()
{
error!("Failed to seed route htlcs stream");
break;
let task_handle = spawn(
"ldk lightning node incoming htlc stream seeder",
async move {
loop {
let node = node_clone.lock().await;
if Self::seed_route_htlcs_stream(&node, &htlc_stream_sender)
.await
.is_err()
{
error!("Failed to seed route htlcs stream");
break;
}
tokio::task::yield_now().await;
}
tokio::task::yield_now().await;
}
});
},
);

let route_htlc_stream: RouteHtlcStream =
Box::pin(ReceiverStream::new(htlc_stream_receiver));
Expand Down Expand Up @@ -234,8 239,12 @@ impl ILnRpcClient for GatewayLdkClient {

// TODO: Do we even need to wait here? `Node.bolt11_payment().send()` might
// already block until the payment is complete.
let start_time = std::time::Instant::now();
while start_time.elapsed() < Duration::from_secs(30) {
let start_time = fedimint_core::time::now();
while fedimint_core::time::now()
.duration_since(start_time)
.unwrap_or_default()
< Duration::from_secs(30)
{
if let Some(payment_details) = self.node.lock().await.payment(&payment_id) {
match payment_details.status {
PaymentStatus::Pending => {}
Expand Down

0 comments on commit 811d33e

Please sign in to comment.