Skip to content

Commit 6bda55e

Browse files
committed
adapt-wasm32-without-fmt
1 parent 63f41fd commit 6bda55e

File tree

28 files changed

+64
-39
lines changed

28 files changed

+64
-39
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ resolver = "2"
55
# as in `ci/ci-tests.sh`.
66
members = [
77
"lightning",
8+
"lightning-common",
89
"lightning-types",
910
"lightning-block-sync",
1011
"lightning-invoice",

lightning-background-processor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ bitcoin_hashes = { version = "0.14.0", default-features = false }
2525
bitcoin-io = { version = "0.1.2", default-features = false }
2626
lightning = { version = "0.1.0", path = "../lightning", default-features = false }
2727
lightning-rapid-gossip-sync = { version = "0.1.0", path = "../lightning-rapid-gossip-sync", default-features = false }
28+
lightning-common = { path = "../lightning-common" }
2829

2930
[dev-dependencies]
3031
tokio = { version = "1.35", features = [ "macros", "rt", "rt-multi-thread", "sync", "time" ] }

lightning-background-processor/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ use core::time::Duration;
4848
#[cfg(feature = "std")]
4949
use core::sync::atomic::{AtomicBool, Ordering};
5050
#[cfg(feature = "std")]
51+
use lightning_common::Instant;
52+
#[cfg(feature = "std")]
5153
use std::sync::Arc;
5254
#[cfg(feature = "std")]
5355
use std::thread::{self, JoinHandle};
54-
#[cfg(feature = "std")]
55-
use std::time::Instant;
5656

5757
#[cfg(not(feature = "std"))]
5858
use alloc::boxed::Box;
@@ -948,7 +948,7 @@ impl BackgroundProcessor {
948948
handle_network_graph_update(network_graph, &event)
949949
}
950950
if let Some(ref scorer) = scorer {
951-
use std::time::SystemTime;
951+
use lightning_common::SystemTime;
952952
let duration_since_epoch = SystemTime::now()
953953
.duration_since(SystemTime::UNIX_EPOCH)
954954
.expect("Time should be sometime after 1970");
@@ -995,7 +995,7 @@ impl BackgroundProcessor {
995995
|time: &Instant, dur| time.elapsed().as_secs() > dur,
996996
false,
997997
|| {
998-
use std::time::SystemTime;
998+
use lightning_common::SystemTime;
999999
Some(
10001000
SystemTime::now()
10011001
.duration_since(SystemTime::UNIX_EPOCH)

lightning-common/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "lightning-common"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
8+
[target.'cfg(target_arch = "wasm32")'.dependencies]
9+
web-time = "1.1"
10+
11+
[lints]
12+
workspace = true

lightning-common/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[cfg(not(target_arch = "wasm32"))]
2+
pub use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
3+
#[cfg(target_arch = "wasm32")]
4+
pub use web_time::{Duration, Instant, SystemTime, UNIX_EPOCH};

lightning-dns-resolver/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ edition = "2021"
1010
[dependencies]
1111
lightning = { version = "0.1.0", path = "../lightning", default-features = false }
1212
lightning-types = { version = "0.2.0", path = "../lightning-types", default-features = false }
13+
lightning-common = { path = "../lightning-common" }
1314
dnssec-prover = { version = "0.6", default-features = false, features = [ "std", "tokio" ] }
1415
tokio = { version = "1.0", default-features = false, features = ["rt"] }
1516

lightning-invoice/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ std = []
2020
[dependencies]
2121
bech32 = { version = "0.11.0", default-features = false }
2222
lightning-types = { version = "0.2.0", path = "../lightning-types", default-features = false }
23+
lightning-common = { path = "../lightning-common" }
2324
serde = { version = "1.0.118", optional = true }
2425
bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery"] }
2526

lightning-invoice/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern crate lightning_types;
2828
extern crate serde;
2929

3030
#[cfg(feature = "std")]
31-
use std::time::SystemTime;
31+
use lightning_common::SystemTime;
3232

3333
use bech32::primitives::decode::CheckedHrpstringError;
3434
use bech32::{Checksum, Fe32};

lightning-liquidity/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ backtrace = ["dep:backtrace"]
2222
lightning = { version = "0.1.0", path = "../lightning", default-features = false }
2323
lightning-types = { version = "0.2.0", path = "../lightning-types", default-features = false }
2424
lightning-invoice = { version = "0.33.0", path = "../lightning-invoice", default-features = false, features = ["serde"] }
25+
lightning-common = { path = "../lightning-common" }
2526

2627
bitcoin = { version = "0.32.2", default-features = false, features = ["serde"] }
2728

lightning-liquidity/src/lsps2/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
88
use bitcoin::hashes::{Hash, HashEngine};
99

1010
#[cfg(feature = "std")]
11-
use std::time::{SystemTime, UNIX_EPOCH};
11+
use lightning_common::{SystemTime, UNIX_EPOCH};
1212

1313
/// Determines if the given parameters are valid given the secret used to generate the promise.
1414
pub fn is_valid_opening_fee_params(

0 commit comments

Comments
 (0)