Skip to content

Commit 863c7f2

Browse files
committed
Improve EsploraSyncClient logging
We give some more information while reducing the log levels to make the logging less spammy.
1 parent f12bf1c commit 863c7f2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lightning-transaction-sync/src/esplora.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::error::{TxSyncError, InternalError};
22
use crate::common::{SyncState, FilterQueue, ConfirmedTx};
33

44
use lightning::util::logger::Logger;
5-
use lightning::{log_error, log_info, log_debug, log_trace};
5+
use lightning::{log_error, log_debug, log_trace};
66
use lightning::chain::WatchedOutput;
77
use lightning::chain::{Confirm, Filter};
88

@@ -14,6 +14,7 @@ use esplora_client::r#async::AsyncClient;
1414
#[cfg(not(feature = "async-interface"))]
1515
use esplora_client::blocking::BlockingClient;
1616

17+
use std::time::Instant;
1718
use std::collections::HashSet;
1819
use core::ops::Deref;
1920

@@ -89,7 +90,10 @@ where
8990
#[cfg(feature = "async-interface")]
9091
let mut sync_state = self.sync_state.lock().await;
9192

92-
log_info!(self.logger, "Starting transaction sync.");
93+
log_trace!(self.logger, "Starting transaction sync.");
94+
let start_time = Instant::now();
95+
let mut num_confirmed = 0;
96+
let mut num_unconfirmed = 0;
9397

9498
let mut tip_hash = maybe_await!(self.client.get_tip_hash())?;
9599

@@ -115,7 +119,7 @@ where
115119
tip_hash = check_tip_hash;
116120
continue;
117121
}
118-
122+
num_unconfirmed += unconfirmed_txs.len();
119123
self.sync_unconfirmed_transactions(&mut sync_state, &confirmables, unconfirmed_txs);
120124
},
121125
Err(err) => {
@@ -152,6 +156,7 @@ where
152156
continue;
153157
}
154158

159+
num_confirmed += confirmed_txs.len();
155160
self.sync_confirmed_transactions(
156161
&mut sync_state,
157162
&confirmables,
@@ -175,7 +180,8 @@ where
175180
sync_state.pending_sync = false;
176181
}
177182
}
178-
log_info!(self.logger, "Finished transaction sync.");
183+
log_debug!(self.logger, "Finished transaction sync at tip {} in {}ms: {} confirmed, {} unconfirmed.",
184+
tip_hash, start_time.elapsed().as_millis(), num_confirmed, num_unconfirmed);
179185
Ok(())
180186
}
181187

0 commit comments

Comments
 (0)