]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Don't call system time in unless feature enabled
authorbenthecarman <benthecarman@live.com>
Sun, 17 Dec 2023 00:08:02 +0000 (18:08 -0600)
committerbenthecarman <benthecarman@live.com>
Tue, 19 Dec 2023 19:22:17 +0000 (13:22 -0600)
ci/check-cfg-flags.py
lightning-transaction-sync/Cargo.toml
lightning-transaction-sync/src/esplora.rs

index 02b598cd447d26a5577883cf17382cd5a2685ea3..277ae1077baad7052fe379f1f8cb5cb1e1ff6f41 100755 (executable)
@@ -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":
index 8cf3e53c416ba1d9295a3a0a49f19969faf7d0ec..a2630400fb33bb690dea8941495ce5493ed7a8d3 100644 (file)
@@ -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"]
index 953f8b0718c3526cff701142c17a0a5d7e32e339..eb52faf33648cfb173985b13c29ecb9d754fdb87 100644 (file)
@@ -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(())
        }