From: benthecarman Date: Sun, 17 Dec 2023 00:08:02 +0000 (-0600) Subject: Don't call system time in unless feature enabled X-Git-Tag: v0.0.120~19^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=f836794e98fcf542a20d26707ef79601e29ef364;p=rust-lightning Don't call system time in unless feature enabled --- diff --git a/ci/check-cfg-flags.py b/ci/check-cfg-flags.py index 02b598cd4..277ae1077 100755 --- a/ci/check-cfg-flags.py +++ b/ci/check-cfg-flags.py @@ -39,6 +39,8 @@ def check_feature(feature): pass elif feature == "electrum": pass + elif feature == "time": + pass elif feature == "_test_utils": pass elif feature == "_test_vectors": diff --git a/lightning-transaction-sync/Cargo.toml b/lightning-transaction-sync/Cargo.toml index 8cf3e53c4..a2630400f 100644 --- a/lightning-transaction-sync/Cargo.toml +++ b/lightning-transaction-sync/Cargo.toml @@ -14,7 +14,8 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [features] -default = [] +default = ["time"] +time = [] esplora-async = ["async-interface", "esplora-client/async", "futures"] esplora-async-https = ["esplora-async", "esplora-client/async-https-rustls"] esplora-blocking = ["esplora-client/blocking"] diff --git a/lightning-transaction-sync/src/esplora.rs b/lightning-transaction-sync/src/esplora.rs index 953f8b071..eb52faf33 100644 --- a/lightning-transaction-sync/src/esplora.rs +++ b/lightning-transaction-sync/src/esplora.rs @@ -14,7 +14,6 @@ use esplora_client::r#async::AsyncClient; #[cfg(not(feature = "async-interface"))] use esplora_client::blocking::BlockingClient; -use std::time::Instant; use std::collections::HashSet; use core::ops::Deref; @@ -91,7 +90,8 @@ where let mut sync_state = self.sync_state.lock().await; log_trace!(self.logger, "Starting transaction sync."); - let start_time = Instant::now(); + #[cfg(feature = "time")] + let start_time = std::time::Instant::now(); let mut num_confirmed = 0; let mut num_unconfirmed = 0; @@ -227,8 +227,12 @@ where sync_state.pending_sync = false; } } + #[cfg(feature = "time")] log_debug!(self.logger, "Finished transaction sync at tip {} in {}ms: {} confirmed, {} unconfirmed.", tip_hash, start_time.elapsed().as_millis(), num_confirmed, num_unconfirmed); + #[cfg(not(feature = "time"))] + log_debug!(self.logger, "Finished transaction sync at tip {}: {} confirmed, {} unconfirmed.", + tip_hash, num_confirmed, num_unconfirmed); Ok(()) }