Skip to content

Commit 2090b02

Browse files
committed
wip
1 parent e174f61 commit 2090b02

2 files changed

Lines changed: 66 additions & 3 deletions

File tree

src/liquidity.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,13 @@ where
11961196
amt_to_forward_msat,
11971197
channel_count
11981198
}) => {
1199+
log_info!(
1200+
self.logger,
1201+
"Handling LSPS4 OpenChannel for peer {} (amt_to_forward_msat={}, channel_count={})",
1202+
their_network_key,
1203+
amt_to_forward_msat,
1204+
channel_count,
1205+
);
11991206
if self.liquidity_manager.lsps4_service_handler().is_none() {
12001207
log_error!(self.logger, "Failed to handle LSPS4ServiceEvent as LSPS4 liquidity service was not configured.",);
12011208
return;
@@ -1232,6 +1239,11 @@ where
12321239
log_error!(self.logger, "Failed to handle LSPS4ServiceEvent as peer manager isn't available. This should never happen.",);
12331240
return;
12341241
};
1242+
log_info!(
1243+
self.logger,
1244+
"LSPS4 OpenChannel peer {} is connected; computing channel size",
1245+
their_network_key,
1246+
);
12351247

12361248
// Fail if we have insufficient onchain funds available.
12371249
let over_provisioning_msat = (amt_to_forward_msat
@@ -1284,6 +1296,14 @@ where
12841296
// succeed.
12851297
return;
12861298
}
1299+
log_info!(
1300+
self.logger,
1301+
"LSPS4 OpenChannel peer {} passed funding checks (channel_amount_sats={}, required_funds_sats={}, spendable_amount_sats={})",
1302+
their_network_key,
1303+
channel_amount_sats,
1304+
required_funds_sats,
1305+
spendable_amount_sats,
1306+
);
12871307

12881308
let mut config = self.channel_manager.get_current_config().clone();
12891309

@@ -1307,6 +1327,13 @@ where
13071327

13081328
// TODO: does LSPS4 service need to track this? seems like no?
13091329
let user_channel_id = 0;
1330+
log_info!(
1331+
self.logger,
1332+
"Calling create_channel for LSPS4 peer {} (channel_amount_sats={}, user_channel_id={})",
1333+
their_network_key,
1334+
channel_amount_sats,
1335+
user_channel_id,
1336+
);
13101337

13111338
match self.channel_manager.create_channel(
13121339
their_network_key,
@@ -1316,7 +1343,14 @@ where
13161343
None,
13171344
Some(config),
13181345
) {
1319-
Ok(_) => {},
1346+
Ok(_) => {
1347+
log_info!(
1348+
self.logger,
1349+
"LSPS4 create_channel accepted for peer {} (channel_amount_sats={})",
1350+
their_network_key,
1351+
channel_amount_sats,
1352+
);
1353+
},
13201354
Err(e) => {
13211355
// TODO: We just silently fail here. Eventually we will need to remember
13221356
// the pending requests and regularly retry opening the channel until we

src/wallet/mod.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::ops::Deref;
1010
use std::pin::Pin;
1111
use std::str::FromStr;
1212
use std::sync::{Arc, Mutex};
13+
use std::time::Instant;
1314

1415
use bdk_chain::spk_client::{FullScanRequest, SyncRequest};
1516
use bdk_wallet::descriptor::ExtendedDescriptor;
@@ -320,7 +321,28 @@ impl Wallet {
320321
pub(crate) fn get_balances(
321322
&self, total_anchor_channels_reserve_sats: u64,
322323
) -> Result<(u64, u64), Error> {
323-
let balance = self.inner.lock().unwrap().balance();
324+
let lock_wait_start = Instant::now();
325+
log_info!(
326+
self.logger,
327+
"Wallet get_balances starting (reserve_sats={})",
328+
total_anchor_channels_reserve_sats,
329+
);
330+
let locked_wallet = self.inner.lock().unwrap();
331+
let lock_wait_ms = lock_wait_start.elapsed().as_millis();
332+
log_info!(
333+
self.logger,
334+
"Wallet get_balances acquired wallet lock in {}ms",
335+
lock_wait_ms,
336+
);
337+
let balance_start = Instant::now();
338+
let balance = locked_wallet.balance();
339+
let balance_ms = balance_start.elapsed().as_millis();
340+
log_info!(
341+
self.logger,
342+
"Wallet get_balances fetched BDK balance in {}ms",
343+
balance_ms,
344+
);
345+
drop(locked_wallet);
324346

325347
// Make sure `list_confirmed_utxos` returns at least one `Utxo` we could use to spend/bump
326348
// Anchors if we have any confirmed amounts.
@@ -332,7 +354,14 @@ impl Wallet {
332354
);
333355
}
334356

335-
self.get_balances_inner(balance, total_anchor_channels_reserve_sats)
357+
let balances = self.get_balances_inner(balance, total_anchor_channels_reserve_sats)?;
358+
log_info!(
359+
self.logger,
360+
"Wallet get_balances computed balances total_sats={} spendable_sats={}",
361+
balances.0,
362+
balances.1,
363+
);
364+
Ok(balances)
336365
}
337366

338367
fn get_balances_inner(

0 commit comments

Comments
 (0)