Skip to content

Commit a8dbe2e

Browse files
committed
Add logging of RPC syncing logic
.. including `TRACE` logs of relevant interval times
1 parent df2fce6 commit a8dbe2e

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/chain/mod.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,14 @@ impl ChainSource {
317317
));
318318
}
319319

320+
log_info!(
321+
logger,
322+
"Starting initial synchronization of chain listeners. This might take a while..",
323+
);
324+
320325
loop {
321326
let mut locked_header_cache = header_cache.lock().await;
327+
let now = SystemTime::now();
322328
match synchronize_listeners(
323329
bitcoind_rpc_client.as_ref(),
324330
config.network,
@@ -329,6 +335,11 @@ impl ChainSource {
329335
{
330336
Ok(chain_tip) => {
331337
{
338+
log_info!(
339+
logger,
340+
"Finished synchronizing listeners in {}ms",
341+
now.elapsed().unwrap().as_millis()
342+
);
332343
*latest_chain_tip.write().unwrap() = Some(chain_tip);
333344
let unix_time_secs_opt = SystemTime::now()
334345
.duration_since(UNIX_EPOCH)
@@ -374,6 +385,8 @@ impl ChainSource {
374385
fee_rate_update_interval
375386
.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
376387

388+
log_info!(logger, "Starting continuous polling for chain updates.");
389+
377390
// Start the polling loop.
378391
loop {
379392
tokio::select! {
@@ -692,13 +705,15 @@ impl ChainSource {
692705
&mut *locked_header_cache,
693706
&chain_listener,
694707
);
695-
let mut chain_polling_interval =
696-
tokio::time::interval(Duration::from_secs(CHAIN_POLLING_INTERVAL_SECS));
697-
chain_polling_interval
698-
.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
699708

709+
let now = SystemTime::now();
700710
match spv_client.poll_best_tip().await {
701711
Ok((ChainTip::Better(tip), true)) => {
712+
log_trace!(
713+
logger,
714+
"Finished polling best tip in {}ms",
715+
now.elapsed().unwrap().as_millis()
716+
);
702717
*latest_chain_tip.write().unwrap() = Some(tip);
703718
},
704719
Ok(_) => {},
@@ -711,11 +726,19 @@ impl ChainSource {
711726
}
712727

713728
let cur_height = channel_manager.current_best_block().height;
729+
730+
let now = SystemTime::now();
714731
match bitcoind_rpc_client
715732
.get_mempool_transactions_and_timestamp_at_height(cur_height)
716733
.await
717734
{
718735
Ok(unconfirmed_txs) => {
736+
log_trace!(
737+
logger,
738+
"Finished polling mempool of size {} in {}ms",
739+
unconfirmed_txs.len(),
740+
now.elapsed().unwrap().as_millis()
741+
);
719742
let _ = onchain_wallet.apply_unconfirmed_txs(unconfirmed_txs);
720743
},
721744
Err(e) => {

0 commit comments

Comments
 (0)