Skip to content

Commit 3c0420c

Browse files
authored
Merge pull request #2799 from benthecarman/tx-sync-wasm
Don't call system time in no-std
2 parents 15b7f66 + f836794 commit 3c0420c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

ci/check-cfg-flags.py

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def check_feature(feature):
3939
pass
4040
elif feature == "electrum":
4141
pass
42+
elif feature == "time":
43+
pass
4244
elif feature == "_test_utils":
4345
pass
4446
elif feature == "_test_vectors":

lightning-transaction-sync/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ all-features = true
1414
rustdoc-args = ["--cfg", "docsrs"]
1515

1616
[features]
17-
default = []
17+
default = ["time"]
18+
time = []
1819
esplora-async = ["async-interface", "esplora-client/async", "futures"]
1920
esplora-async-https = ["esplora-async", "esplora-client/async-https-rustls"]
2021
esplora-blocking = ["esplora-client/blocking"]

lightning-transaction-sync/src/esplora.rs

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

17-
use std::time::Instant;
1817
use std::collections::HashSet;
1918
use core::ops::Deref;
2019

@@ -91,7 +90,8 @@ where
9190
let mut sync_state = self.sync_state.lock().await;
9291

9392
log_trace!(self.logger, "Starting transaction sync.");
94-
let start_time = Instant::now();
93+
#[cfg(feature = "time")]
94+
let start_time = std::time::Instant::now();
9595
let mut num_confirmed = 0;
9696
let mut num_unconfirmed = 0;
9797

@@ -227,8 +227,12 @@ where
227227
sync_state.pending_sync = false;
228228
}
229229
}
230+
#[cfg(feature = "time")]
230231
log_debug!(self.logger, "Finished transaction sync at tip {} in {}ms: {} confirmed, {} unconfirmed.",
231232
tip_hash, start_time.elapsed().as_millis(), num_confirmed, num_unconfirmed);
233+
#[cfg(not(feature = "time"))]
234+
log_debug!(self.logger, "Finished transaction sync at tip {}: {} confirmed, {} unconfirmed.",
235+
tip_hash, num_confirmed, num_unconfirmed);
232236
Ok(())
233237
}
234238

0 commit comments

Comments
 (0)